C/string.h/strerror

Материал из C\C++ эксперт
Версия от 10:22, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

strerror(errno)

#include <stdio.h>
#include <string.h>
#include <errno.h>
int main ()
{
  FILE * pFile;
  pFile = fopen ("unexist.ent","r");
  if (pFile == NULL)
    printf ("Error opening file unexist.ent: %s\n",strerror(errno));
  return 0;
}
         
/*
Error opening file unexist.ent: No such file or directory (ENOENT)
*/


strerror: returns error message associated with the errnum

    
//Declaration:  char *strerror(int errnum); 
//Return:       returns error message associated with the errnum. 
#include<string.h>
#include<stdio.h>
int main(void){
  printf(strerror(10));
}