八、函数
#include #include #include #include #include #include #include #include #include #include int main(){pid_t pid;int data = http://www.kingceram.com/post/10;while(1){printf("please input a data\n");scanf("%d",&data); if(data =http://www.kingceram.com/post/= 1){int fdSrc;pid = fork();if(pid> 0){wait(NULL);}if(pid == 0){//execl("./changData","changData","config.txt",NULL);system("./changData config.txt");}}else{printf("wait ,do nothing\n");}}return 0;}
九、poen函数
poen比在应用中的好处:
可以获取运行的输出结果
#include #include #include //int execl(const char *path, const char *arg, ...);//size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)int main(void){char ret[1024] = {0};FILE *fp;fp = popen("ps","r");int nread = fread(ret,1,1024,fp); printf("read ret %d byte, ret=%s\n",nread,ret);return 0;}