问题:在完成课后习题的时候,使用fopen()函数以"a+"方式打开一个不存在的文件时,写入、读取出现错误;

1 //添加用户输入单词后,在单词头加入编号,确保编号跟着前面的开始排序 2 #include "stdio.h" 3 #include "stdlib.h" 4 #define MAX 40 5 6 int main(void){ 7 FILE *fp; 8 char words[MAX]; 9 int count = 1, 10 temp; 11 12 if((fp = fopen("words.txt", "a+")) == NULL){ 13 fprintf(stderr, "打开文件"words"失败! "); 14 exit(1); 15 } 16 17 //从最后一个序号开始继续排序 18 fseek(fp, 0L, SEEK_SET); 19 while(1){ 20 if(fscanf(fp, "%d", &temp) != 1) 21 break; 22 else 23 count++; 24 } 25 puts("输入单词添加到文件中:"); 26 while(gets(words) != NULL && words[0] != '