I would write a program as follows
int main ()
{
FILE *fp = fopen("test.txt", "r")
if (fp == NULL)
{
printf("Sorry, file doesn't exist.");
return 0;
}
return 0;
}
Is there any other check that I will need to check before or after opening the file?
What to do if opening a file can damage the system (virus)? Is there a check for this?
What if the file is not a .txt file, the user simply renamed the mp3 file to a txt file?
source
share