我花了一段时间才弄清楚这个错误,并想知道为什么第二个代码块不起作用。
在职的:
FILE *readFile;
FILE *saveFile;
char readFileName;
char saveFileName;
printf("read file name:\n");
scanf("%s", &readFileName);
readFile = fopen(&readFileName, "r");
printf("save file name:\n");
scanf("%s", &saveFileName);
saveFile = fopen(&saveFileName, "w");
没用:
FILE *readFile;
FILE *saveFile;
char readFileName;
char saveFileName;
printf("read file name:\n");
scanf("%s", &readFileName);
printf("save file name:\n");
scanf("%s", &saveFileName);
readFile = fopen(&readFileName, "r");
saveFile = fopen(&saveFileName, "w");