How can I delete a file pointed to by a FILE* in C?

前端 未结 5 1536
予麋鹿
予麋鹿 2021-01-19 04:56
#include

int main() {

    FILE* fp;
    fp = fopen(\"temp.txt\", \"w\");
    fprintf(fp, \"Hello, World!\\n\");

    // remove(\"temp.txt\");  this          


        
5条回答
  •  不知归路
    2021-01-19 05:27

    No, you can't. And FILE struct doesn't include filename inside it. So best option is to have structure that will both hold pointer to FILE and to char* with name

提交回复
热议问题