How would I know if a file exists in my current directory in C? I'm prompting the user and I'm trying to see if the file they type in already exists or not. Here's what I got:
int a=0;
char ing[100];
FILE * inp;
while (a=0);
{
printf("Input file name: ");
scanf("%s", ing);
inp=fopen(ing , "r");
if (inp==NULL)
a=0;
else
a=1;
}
Whenever I type in a file that doesn't exist, I get that the cmd isn't responding. Whenever I type something that exists, it works fine, which is good. I just don't know what exactly I would need to put in if NULL doesn't work.