void perror(const char *s);
The perror() function shall map the error number accessed through the symbol errno to
a language-dependent error message, which shall be written to the standard error
stream as follows:
First (if s is not a null pointer and the character pointed to by s is not
the null byte), the string pointed to by s followed by a colon and a <space>.
Then an error message string followed by a <newline>.
Simply perror will retun a message corresponding to errno. The
errno is a special system variable that is set if a system call cannot
perform its set task.
The perror() function shall not return a value.
extern int errno ;
int main ()
FILE * pFile;
pFile = fopen ("unexist.ent","rb");
if (pFile == NULL)
perror ("The Below error occurred");
printf( "Value of errno: %d\n", errno );
If file unexist.ent does not exit then it will produce following Output Will Be :
The Below error occurred: No such file or directory
Value of errno: 29
Your Query was successfully sent!