#include<stdio.h>
#include<ctype.h>
int main() {
FILE *fpin = fopen("in.txt", "r");
fprintf(fpin, "hello, world!");
fclose (fpin);
char c;
fpin = fopen("in.txt", "r");
FILE *fpout = fopen("out.txt", "w");
while ((c = fgetc(fpin)) != EOF) {
fputc (toupper(c), fpout);
}
fclose (fpout);
fclose (fpin);
return 0;
}
我得到一个
分段故障
谢谢您。
最佳答案
我对C一无所知,但似乎是你写的文件,你已经打开只读。。。
FILE *fpin = fopen("in.txt", "r");
fprintf(fpin, "hello, world!");
可能是:
FILE *fpin = fopen("in.txt", "w");
fprintf(fpin, "hello, world!");