实践过程截图,遇到问题GPT求解,代码链接
#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; }









浙公网安备 33010602011771号