环境:Vmware Workstation;CentOS-6.4-x86_64

说明:

1、system函数的定义形式:int system(const char *command);

2、system函数的参数是Linux系统下可以执行的命令。

程序如下:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *args[])
{
// 打开日历
system("cal");
// 查看文件
system("ls");
return 0;
}

执行效果:

[negivup@negivup mycode]$ gcc -o main main.c
[negivup@negivup mycode]$ ./main
九月 2015

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

main main.c