When the file does not exist when reading in C language, you can directly write the file and create the file

FILE *fp;
fp= fopen("test.ini","r");
if(!fp)
{
   fp = fopen("test.ini","w");
   //fputs();
}

By default, we want to read the file. If the file does not exist, fopen will return NULL. At this time, we will use the write attribute to recreate the file.

 

Guess you like

Origin blog.csdn.net/modi000/article/details/113882369