gpt4 book ai didi

c - 无论标志如何,来自二进制的 fread 返回相同

转载 作者:太空宇宙 更新时间:2023-11-04 05:59:36 24 4
gpt4 key购买 nike

<分区>

首先我有这个:

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

如果两次都做同样的事情,那么标志有什么意义?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com