#inlcude<stdlib.h>
int system(const char* command)
功能:在已經運行的程序中調用另一個外部程序
參數:外部可執行程序的名字
返回值:不同系統的返回值不一樣
實例程序
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("before sys\n");
system("ls");
//system("ls -alh");
//查看執行程序所在目錄下的所有目錄內容
//Linux下(運行一個程序需要加./)
// system("./hello");
//windows(運行一個程序不需要加./)
// system("hello"); // system("calc"); //計算器
//hello為該程序目錄下的可執行文件,程序會在執行到system的時候,調用hello這個程序
printf("after sys\n");
return 0;
}
結果