我试图创建mydata.txt并从中读取,但编译器给出的结果是
001682686832
这个代码出了什么问题?
int main()
{
double f_1, f_2;
int i_1, i_2;
FILE *file_pointer;
char file_name[SIZE] = "mydata.txt";
file_pointer = fopen(file_name, "w");
fprintf(file_pointer, "%f %f %d %d", 23.556, -76e5, 76, 5);
file_pointer = fopen(file_name, "r");
fscanf(file_pointer, "%lf %lf %ld %ld", &f_1, &f_2, &i_1, &i_2);
fclose(file_pointer);
printf("%fn", f_1);
printf("%fn", f_2);
printf("%dn", i_1);
printf("%dn", i_2);
getch();
return 0;
}
在第二个fopen()
之前执行fclose()
。