摘要: #include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <fcntl.h>#include <stdio.h>int main(){ struct stat buf; int fd = open("/etc/pas 阅读全文
posted @ 2016-02-19 16:54 聚沙成塔 阅读(556) 评论(0) 推荐(0) 编辑
摘要: #include <dirent.h>#include <stdio.h>#include <stdlib.h>int main(int argc, char *argv[]){ DIR *dp; struct dirent *dirp; if (argc != 2) { printf("usage 阅读全文
posted @ 2016-02-19 16:26 聚沙成塔 阅读(493) 评论(0) 推荐(0) 编辑
摘要: 静态库所要用的源文件 文件 fred.c #include <stdio.h> void fred(int argc) { printf("void fred(int argc) | argc is [%d]\n", argc); } 文件 bill.c #include <stdio.h> voi 阅读全文
posted @ 2016-02-19 16:14 聚沙成塔 阅读(1134) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <stdlib.h> int main(int argc, char ** argv) { printf("hello world!\n"); exit(0); } 编译、链接和运行 gcc -o hello hello.c ./hello 另 阅读全文
posted @ 2016-02-19 16:13 聚沙成塔 阅读(193) 评论(0) 推荐(0) 编辑
摘要: /* * 该程序是练习read(),write(),open(),create(),close(),lseek()等函数。 * * 该程序的处理思路: * 1: 在程序所在的目录去打开一个文件,如果该文件不存在,则创建他。 * 2:然后读取/etc/passwd文件的内容,并将内容写入打开的文件。  阅读全文
posted @ 2016-02-19 16:10 聚沙成塔 阅读(454) 评论(0) 推荐(0) 编辑