Print error message: how to use perror : error « Development « C / ANSI-C






Print error message: how to use perror


#include <stdio.h>

int main ()
{
  FILE *file;
  
  file=fopen ("my.ent", "rb");
  
  if (file==NULL)
    perror ("An error has occurred");
  else
    fclose (file);
  return 0;
}


           
       








Related examples in the same category

1.Reset error indicators: writing errors
2. Get pointer to error message string: how to use strerror
3.Define Macro for string variable
4.Preprocessor: error
5.Preprocessor: line