struct FATEntry entry1;
strcpy(entry1.name, "abc");
entry1.next = 3;
entry1.size = 10;
entry1.mtime = 100;
struct FATEntry entry2;
strcpy(entry1.name, "");
entry1.next = 0;
entry1.size = 0;
entry1.mtime = 0;
struct FATEntry entry3;
strcpy(entry1.name, "foo");
entry1.next = 324;
entry1.size = 3;
entry1.mtime = 434;
file1 = fopen("filesys", "r+b");
fwrite(&entry1, sizeof(struct FATEntry), 1, file1);
fseek(file1,BLOCK_SIZE,SEEK_SET);
fwrite(&entry3, sizeof(struct FATEntry), 1, file1);
fseek(file1,BLOCK_SIZE,SEEK_SET);
fread(&entry2, sizeof(struct FATEntry), 1, file1);
fclose(file1);
所以基本上我在这里要做的是将entry1写入文件然后寻找512字节(因为这将是一个块)然后将entry3写入文件。但是当我担心我应该从 entry3 获取值但进入 entry2 时,但我在 entry2 中看到的只是随机数。我究竟做错了什么?