The C library function void perror(const char *str) prints a descriptive error message to stderr. First the string str is printed followed by a colon then a space. Syntax : void perror (const char *str) where str is the user defined message that prints before the actual error message.