关闭和打开时从二进制文件中读取

Reading from a binary file when closing and opening it

我试图通过关闭和打开二进制文件来读取它,但它似乎不起作用。

当我将其更改为 wb+ 并使用注释掉的 fseek 而不是关闭和打开时,它会读取。我在关闭和打开文件时做错了什么?

int main(){
    FILE * tfp = fopen("test.bin", "wb");
    char src[] = "1233 asd 333";
    fputs(src, tfp);

    char aw[20];

    //fseek(tfp, SEEK_SET, 0);
    fcloseall;

    tfp = fopen("test.bin", "rb");
    fread(aw, sizeof(char), 20, tfp);

    fcloseall;
    getchar();
}

问题是 fcloseall; 而不是 fcloseall();