C Standard Libraries C++

strerror()

Declaration

char* strerror(int iErrorNumber);

Description

This function returns a pointer to a string containing the error message corresponding to the error number given by "iErrorNumber."

Example

#include <cstdio>
#include <cstring>

int main()
{
    // Output the first 10 error messages
    for (int iIndex = 0; iIndex < 10; ++iIndex) {
        char* cpErrorMsg = strerror(iIndex);
        printf("Error number %i is %s\n", iIndex, cpErrorMsg);
    }
    return 0;
}

Output

strerror() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.