比如有个txt.txt文本里面有些数字:
***********
251525
***********
4541151
***********
等等。。。
怎么能读到另一个文件里面?
參考答案:#include <stdio.h>
void main()
{
FILE * fpread;
FILE * fpwrite;
if ((fpread = fopen("txt.txt", "r")) == NULL)
{
printf("Cannot open txt.txt for reading!\n");
return;
}
if ((fpwrite = fopen("output.txt", "w")) == NULL)
{
printf("Cannot open output.txt for writing!\n");
return;
}
long num;
while (fscanf(fpread, "%d", &n) != EOF)
{
fprintf(fpwrite, "%d", n);//这一句你自己改,看你要干什么了
}
fclose(fpread);
fclose(fpwrite);
}