perror(s) outputs the string s on stderr, followed by an error message which describes or elaborates the error code currently stored in errno. It is equivalent to:
fprintf(stderr, "message")where error message is a string describing whatever error condition is represented by the current value of errno.
perror() might usefully be called on any occasion when your program detects that a standard library function has failed to operate as expected.