Linux中运行c程序,与系统打交道

例一:system系统调用是为了方便调用外部程序,执行完毕后返回调用进程。

#include <stdio.h>
#include <stdlib.h>
main()
{
    printf("call ls return %d\n",system("pstree -p"));
}

 gcc -o jingce jingce.c 编译成可执行文件

然后 ./jingce

posted @ 2015-03-11 10:43  kin2321  阅读(233)  评论(0编辑  收藏  举报