p2-1.c
来自「UNIX程序设计教程」· C语言 代码 · 共 22 行
C
22 行
#include <stdio.h>int main(void){ FILE *stream; char buf[80]; printf("open and creat test_file\n"); if ((stream = fopen("test_file","w")) == NULL ){ perror("open() failed"); exit(1); } printf("write string to test_file\n"); fputs("Hello world",stream); if ((stream = freopen("test_file","r",stream)) == NULL ){ perror("open() failed"); exit(1); } printf("read string from test_file\n"); fgets(buf, sizeof(buf), stream); printf("the string is \"%s\"\n", buf); fclose(stream);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?