随笔分类 -  Linux/Unix系统编程

学习APUE、Linux/Unix系统编程手册时候的点滴记录
摘要:#include <unistd.h> #include <stdio.h> int main() { enum {PATHMAX = 256}; char buf[PATHMAX]; int val; char *cwd; cwd = getcwd(buf, PATHMAX); /*remembe 阅读全文
posted @ 2021-07-05 11:14 东宫得臣 阅读(139) 评论(0) 推荐(0) 编辑
摘要:#include <errno.h> #include <string.h> #include <stdio.h> #include <fcntl.h> int main() { int fd, ret; enum { LENGTH = 100 }; char buf[LENGTH]; fd = o 阅读全文
posted @ 2020-09-09 15:02 东宫得臣 阅读(420) 评论(0) 推荐(0) 编辑
摘要:int find_file_in_dir(const char *path, const char *file) { struct dirent *entry; int ret=1; DIR *dir; dir = opendir(path); errno = 0; while((entry = r 阅读全文
posted @ 2020-08-17 21:35 东宫得臣 阅读(143) 评论(0) 推荐(0) 编辑
摘要:#include <sys/stat.h> int stat(const char *restrict pathname, struct stat *restrict buf); struct stat { mode_t st_mode; /*file type & mode(permissions 阅读全文
posted @ 2018-09-22 10:15 东宫得臣 阅读(3823) 评论(1) 推荐(1) 编辑
摘要:#include <stdio.h>#include <stdlib.h>#include <arpa/inet.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/time.h>#include <netinet/in.h>#i 阅读全文
posted @ 2018-03-31 14:48 东宫得臣 阅读(194) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h>#include <stdlib.h>#include <arpa/inet.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/time.h>#include <netinet/in.h>#i 阅读全文
posted @ 2018-03-31 14:36 东宫得臣 阅读(185) 评论(0) 推荐(0) 编辑
摘要:我们在一个短整数变量中存放2字节的值0x0102,然后查看它的 两个连续字节c[0]和c[1],以此确定字节序。 #include <unistd.h>#include <stdio.h> int main() { union { short s; char c[sizeof(short)]; } 阅读全文
posted @ 2018-03-30 13:59 东宫得臣 阅读(179) 评论(0) 推荐(0) 编辑
摘要:#include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/wait.h> #include <s 阅读全文
posted @ 2018-01-15 07:58 东宫得臣 阅读(191) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示