为什么C语言读入一个文本文件并把其内容输出到一个新的文本文件当中,为什么我的古诗2运行后是乱码啊
代码是
#include <stdio.h>
#include <stdlib.h>
int main()
{
char name[50]="C:\\C语言\\test_10_22\\古诗.txt";//name存放我们要读入的文本文件名
FILE * fp=fopen(name,"r");
if(fp==NULL)
{
printf("文件打开失败,程序退出\n");
exit(-1);
}
FILE * fp2=fopen("C:\\C语言\\test_10_22\\古诗2.txt","w");
if(fp2==NULL)
{
printf("文件打开失败,程序退出\n");
exit(-1);
}
char ch;
while(ch=fgetc(fp)!=EOF)
fputc(ch,fp2);
fclose(fp);
fclose(fp2);
return 0;
}