C examples for stdio.h:perror
function
<cstdio> <stdio.h>
Print error message
void perror ( const char * str );
Parameter | Description |
---|---|
str | C string containing a custom message to be printed before the error message itself. |
none
#include <stdio.h> int main ()// w ww .jav a 2s. c o m { FILE * pFile; pFile=fopen ("unexist.ent","rb"); if (pFile==NULL){ perror ("The following error occurred"); return -1; } fclose (pFile); return 0; }