文件中的开头内容是明明是空格,为什么却输出了1
#include<stdio.h>
#include<stdlib.h>
int main()
{
int i, n;
FILE* fp;
if ((fp = fopen("temp", "w+")) == NULL)
{
exit(0);
}
for (i = 1; i <= 10; i++)
fprintf(fp, "%3d", i);
/*for (i = 0; i < 5; i++)
{
fseek(fp, i * 6L, SEEK_SET);
fscanf(fp, "%d", &n);
printf("%3d", n);
}*/
fseek(fp, 0, SEEK_SET);
fscanf(fp, "%d", &n);
printf("%3d", n);
printf("\n");
fclose(fp);
return 0;
}