Public Domain
#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;
}
BY: Pejman Moghadam
TAG: c, error, strerror, errno
DATE: 2014-01-15 22:34:35