C语言 从二进制文件中读取关闭和打开它



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

当我将其更改为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();

最新更新