摘要: 编写程序,子进程通过管道向父进程发出字符串"ok". 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 int main(void) { 5 int data_processed; //用于记录已经处理的数据 6 int file_pipes[2]; //定义两个文件描述符 7 char buffer[BUFSIZ + 1]; //定义一个缓冲区,以便从管道中读取数据 8 const char * some_data = "OK"; / 阅读全文
posted @ 2013-01-20 07:42 陈哈哈 阅读(2573) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 int main(void) { 5 int data_processed; //用于记录已经处理的数据 6 int file_pipes[2]; //定义两个文件描述符 7 char buffer[BUFSIZ + 1]; //定义一个缓冲区,以便从管道中读取数据 8 const char * some_data = "123"; //定义一个将要写入管道中的字符串 9 memset(buffer, &# 阅读全文
posted @ 2013-01-20 07:25 陈哈哈 阅读(701) 评论(0) 推荐(0) 编辑
摘要: 分别用系统调用和标准库函数两种方式编写一个程序对文件逐个字符进行拷贝,其中源文件名为"./file.in"是一个二进制文件,目标文件名是"./file.out",目标文件的权限为文件属性为:可读可写 1 /* 2 ============================================================================ 3 Name : test_cp.c 4 Author : 5 Version : 6 Copyright : Your copyright notice 7 Description... 阅读全文
posted @ 2013-01-20 06:43 陈哈哈 阅读(570) 评论(0) 推荐(0) 编辑
摘要: 1 #include <unistd.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <dirent.h> 5 #include <string.h> 6 #include <sys/stat.h> 7 /** 8 * 将数据的目录和深度一起传进来 9 */10 void printfdir(char *dir, int depth) {11 12 DIR * dp; //对目录进行操作13 struct dirent *entry; //对目录的数据项进行 阅读全文
posted @ 2013-01-20 06:30 陈哈哈 阅读(4244) 评论(0) 推荐(0) 编辑