C Programming
Computer Programming

C file handling program to check a specified directory exists or not



Write C file handling program to check a specified directory exists or not

\* C file handling program to check a specified directory exists or not *\

# include < stdio.h >
int   main( )
{

FILE* filePtr ;
char filename[20] ;
printf("\n Enter the filename to be opened : ") ;
scanf("%s", filename );
filePtr = fopen(filename, "r") ;
if (filePtr == NULL)
{
      printf(" file does not exists.\n") ;
      return 1 ;
}
printf(" file exists.\n") ;
fclose(filePtr) ;
return 0 ;

}

Output of Program :

Output of C file handling program to check a specified directory exists or not