我做错了什么?该文件运行后为空(适用于char
)。不知道为什么。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
main()
{
float marks[256][6];
FILE *f= fopen("test.bin", "rb+");
fread(marks, sizeof(float), sizeof(marks), f);
marks[0][0] = 50;
marks[0][1] = 50;
marks[0][2] = 50;
marks[0][3] = 50;
marks[0][4] = 50;
marks[0][5] = 50;
fwrite(marks, sizeof(float), sizeof(marks), f); // Is this correct?
fclose(f);
}