【发布时间】:2014-02-21 11:29:54
【问题描述】:
首先我有这个:
int main (void)
{
int m = 10;
double x[3] = {1.5, -3.5, 3.25};
int n1, n2; FILE *izTok;
izTok = fopen ("podaci.bin", "wb");
n1 = fwrite (&m, sizeof(m), 1, izTok);
n2 = fwrite (x, sizeof(x[0]), 3, izTok);
fclose(izTok);
return 0;
}
然后我尝试用
读取它 FILE *stream;
stream = fopen("podaci.bin", "r");
n1 = fread(&n, sizeof(n), 1, stream);
n2 = fread(arr, sizeof(arr[0]), 3, stream);
printf("%d %f %f %f", n, arr[0], arr[1], arr[2]);
而且不管我有没有放
stream = fopen("podaci.bin", "r");
或
stream = fopen("podaci.bin", "rb");
输出是一样的
10 1.500000 -3.500000 3.250000
如果两次都做同样的事情,标志的意义何在?
【问题讨论】:
标签: c