我的文本文件是这样的:
0 000 fff1
0 121 afaada4
0 000 mm1m1
我一直在努力做这样的事情:
if (fi) {
while(fscanf(fi,"%d" "%d" "%s",&sigs1,&sigs2,&sigs3)!=EOF);
printf("%d %d %s",sigs1,sigs2,sigs3);
fclose(fi);
}
答案 0 :(得分:0)
#include <stdio.h>
int main() {
int sigs1, sigs2;
char * sigs3;
FILE *fi;
fi = fopen("text.txt", "r");
if (fi) {
while(fscanf(fi,"%d " "%d" "%s ",&sigs1,&sigs2,sigs3)!=EOF)
printf("%d %03d %s\n",sigs1,sigs2,sigs3);
fclose(fi);
}
return 0;
}
测试
0 000 fff1
0 121 afaada4
0 000 mm1m1