In C++, strerror() turns an error number into a short message you can print. You usually pass errno right after a library call fails.
The error number is required. The result is a pointer to text that the library owns, so do not free it or change it. Read errno before another call replaces it. Include <cstring> and <cerrno>.
Syntax
Pass the error number. That is usually errno just after a call fails.
C++
strerror(errno);
Call
What it does
strerror(errno)
Returns a message for the current error number.
Library declarations
C++
char* strerror(int errnum);
Parameters
Parameter
Description
errnum
Required. The error number, usually errno right after the call that failed.
Return Value
Return Value
Description
Message
A pointer to text that describes the error. The library owns that text.