perror()

Declaration

void perror(const char* kcpString);

Description:

This function outputs the string "kcpString" to the stream "stderr" for error reporting. The output is the string "kcpString," followed by a colon, and then the last system error message. The last error is stored in the variable errno.

Example

#include <cstdio>

int main()
{
    char* cpFileName = "XoaX.net";
    // Try to open a file that doesn't exist
    FILE* qpFile = fopen(cpFileName, "r" );

    // Check that the file was opened successfully.
    if (!qpFile) {
        perror("Could not open the file");
        return 1;
    }

    fclose(qpFile);

    return 0;
}

Output:

perror() Output