两个txt文本文件没有空格,可是读取到char数组显示中间有空格
#include<stdio.h>#include<stdlib.h>
#include<string.h>
int main()
{
FILE *fp1, *fp2;
char ar[200];
if((fp1 = fopen("新建文本文档.txt","r")) == NULL)
{
printf("打开文件失败.\n");
exit(0);
}
if((fp2 = fopen("新建文本文档 (2).txt","r")) == NULL)
{
printf("打开文件失败.\n");
exit(0);
}
int i;
for(i = 0; !feof(fp1); i++)
{
ar[i] = fgetc(fp1);
}
while(!feof(fp2))
{
ar[i] = fgetc(fp2);
i++;
}
ar[i] = '\0';
printf("%s\n",ar);
system("pause");
return 0;
}