User Tools

Site Tools


c:error_checking

This is an old revision of the document!


C - Error Checking

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main()
{
  FILE *fp;
  char errmsg[200];
 
  fp = fopen("Nofile", "r");
  if (fp == NULL) {
    perror("fopen");
    /*
     *  strerror_r(errno, errmsg, sizeof(errmsg));
     *  printf("fopen: %s(%d)\n", errmsg, errno); 
     *
     */
     exit(EXIT_FAILURE);
  }
 
  return 0;
}
c/error_checking.1467420345.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki