User Tools

Site Tools


c:error_checking

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.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki