#include <stdio.h> int main() { FILE *file; file = fopen("er.txt", "w"); if (file == NULL) { printf("Cannot open file\n"); return 1; } fprintf(file, "Hello, World!\n"); fclose(file); file = fopen("er.txt", "r"); if (file == NULL) { printf("Cannot open file\n"); return 1; } char line[100]; while (fgets(line, sizeof(line), file) != NULL) { printf("%s", line); } // 关闭文件 fclose(file); return 0; }
标签:截图,return,fclose,file,printf,GPT,line,NULL,链接 From: https://www.cnblogs.com/sjd-sr/p/17707371.html