C语言文件的读取和写入不成功是什么原因啊。
感觉是最基本的代码了 但是跑程序之后 to 文件里面并没有写入成功
#include<string.h>
#include<stdio.h>
#include <stdlib.h>
int main()
{
FILE *from, *to;
char temp[100];
to = fopen("1.txt", "r");
from = fopen("2.txt", "w");
perror("1.txt");
perror("2.txt");
while (fgets(temp, 100, from) != NULL)
{
fputs(temp, to);
fflush(to);
}
fclose(from);
fclose(to);
system("pause");
return 0;
}