64,662
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main()
{
FILE* file;
if(fopen_s(&file,"test.txt","r")!=0)
{
printf("打开文件失败!\n");
return 0;
}
char buff[512];
while (!feof(file))
{
fscanf_s(file,"%[^;]",buff);
fgetc(file);
}
fclose(file);
}
int main()
{
FILE* file;
if(fopen_s(&file,"dest.txt","r")!=0)
{
printf("打开文件失败!\n");
return 0;
}
char buff[512];
while (!feof(file))
{
fscanf_s(file,"%[^;]",buff, 100); //加上长度信息就对了。。。scanf_s类似,需要指定长度
//fscanf(file,"%[^;]",buff);
fgetc(file);
puts(buff);
}
fclose(file);
system("PAUSE");
}