⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p2-10.c

📁 SUN Solaris8平台下进程间通信
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include "err_exit.h"char buf[132];int get_line(char *,int size, FILE *);     /* 程序2-8 */int main(void){    FILE *fd;    /* 创建一个文件并写入二行数据 */    if ((fd = fopen("test_file","w+")) == NULL)        err_exit("fopen faild");    fprintf(fd,"this is first line.\n");    fprintf(fd,"this is second line.\n");    fclose(fd);    /* 再次打开该文件读写数据*/    if ((fd = fopen("test_file","r+")) == NULL)        err_exit("fopen faild");    /* 读一行数据 */    get_line(buf, sizeof(buf), fd);    /* 由读变为写 */    /* fflush(fd); */     fprintf(fd,"I hope this line become the new second line.\n");    /* 由写变为读 */    /* fflush(fd); */      get_line(buf, sizeof(buf), fd);    fclose(fd);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -