摘要: #include<stdio.h>#include<stdlib.h>#include<sys/wait.h>#define MAXLINE 4096int main(){ char buf[MAXLINE]; pid_t pid; int status; while(fgets(buf,MAXLINE,stdin) != NULL){ if(buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = 0; if((pid = fork()) < 0){ ... 阅读全文
posted @ 2013-04-06 14:27 孤独的小马哥 阅读(485) 评论(0) 推荐(0)
摘要: #include<stdio.h>#include<stdlib.h>#include<dirent.h>int main(int argc,char **argv){ DIR *dp; struct dirent *dirp; if(argc != 2){ printf("usage:ls directory_name\n"); exit(0); } if((dp = opendir(argv[1])) == NULL){ printf("can not open\n"); exit(0); ... 阅读全文
posted @ 2013-04-06 13:55 孤独的小马哥 阅读(209) 评论(0) 推荐(0)