System函数的使用说明


#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;
}

结果

1


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM