文件输入后面有乱码/急急急
请问为什么输入后尾端总带有乱码??#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 50
int main()
{
char a,b;
FILE *f;
f = fopen("D://Hellow.txt","r+");
if(NULL == f)
{
printf("wrong");
exit(0);
}
strcpy(a,"second\nthird\nfourth");
fputs("this is a new world",f);
strcpy(b,"fifthhhhh");
fputs(b,f);
while(fgets(b,SIZE,f))
{
printf("%s",b);
}
fclose(f);
return 0;
}
a和b 是不是少了 '\0'结束符呢 chxchxkkk 发表于 2020-5-22 09:27
a和b 是不是少了 '\0'结束符呢
是要写入后直接关掉要读取时重新打开文件
页:
[1]