perror()

Output an error message to stderr.

  #include <stdio.h>
  
  void perror(const char *s);    
Parameter

s

Error message to print.

Remarks

If s is not NULL or a pointer to a null string the perror() function outputs to stderr the character array pointed to by s followed by a colon and a space " : " . Then, the error message that would be returned by strerror() for the current value of the global variable errno.

Listing: Example of perror() Usage

#include <errno.h>

#include <stdio.h>

int main()

{

perror("No error reported as");

errno = EDOM;

perror("Domain error reported as");

errno = ERANGE;

perror("Range error reported as");

return 0;

}

Output

No error reported as: No Error

Domain error reported as: Domain Error

Range error reported as: Range Error

Input and Output for Wide Characters and Multibyte Characters

Facilities for reading and writing wide and multibyte characters.