| Previous | Home | Next |
Description
The C library function, The perror() function The C library function the value of the global variable errno onto a string and writes that string to stderr. If the value of str is not null, it is written first, followed by a colon, and then the implementation-defined error message.
Declaration
Following is the declaration for perror() function.
void perror(const char *str)
Parameters
str - pointer to a null-terminated string with explanatory message.
Return Value
The perror function returns not return a value.
Example
#include <stdio.h>
int main ()
{
FILE * p;
p=fopen ("content.txt","rb");
if (p==NULL)
perror ("The following error occurred");
else
fclose (p);
return 0;
}
Output
The following error occurred: No such file or directory
| Previous | Home | Next |