C Standard Libraries C++



extern int errno;


This variable is hold a value that designates a system-level error. The perror() function prints out a message corresponding this the set error value in errno when it is called. A value of zero indicates no error. The other error values are given in the table below.

errno Value Table


EPERMOperation not permitted1
ENOENTNo such file or directory2
ESRCHNo such process3
EINTRInterrupted function4
EIOI/O error5
ENXIONo such device or address6
E2BIGArgument list too long7
ENOEXECExec format error8
EBADFBad file number9
ECHILDNo spawned processes10
EAGAINNo more processes, not enough memory, or maximum nesting level reached11
ENOMEMNot enough memory12
EACCESPermission denied13
EFAULTBad address14
EBUSYDevice or resource busy16
EEXISTFile exists17
EXDEVCross-device link18
ENODEVNo such device19
ENOTDIRNot a directory20
EISDIRIs a directory21
EINVALInvalid argument22
ENFILEToo many files open in system23
EMFILEToo many open files24
ENOTTYInappropriate I/O control operation25
EFBIGFile too large27
ENOSPCNo space left on device28
ESPIPEInvalid seek29
EROFSRead-only file system30
EMLINKToo many links31
EPIPEBroken pipe32
EDOMMath argument33
ERANGEResult too large34
EDEADLKResource deadlock would occur36
EDEADLOCKSame as EDEADLK for backward compatibility36
ENAMETOOLONGFilename too long38
ENOLCKNo locks available39
ENOSYSFunction not supported40
ENOTEMPTYDirectory not empty41
EILSEQIllegal byte sequence42
STRUNCATEString was truncated80


#include <iostream>
#include <cerrno>

int main() {
    using namespace std;

    // Print the message before we set the error value.
    cout << "errno = " << errno << endl;
    // Set errno to an error value.
    errno = 3;
    cout << "errno = " << errno << endl;
    // Use the same error value with an appended message.
    cout << "errno = " << errno << endl;

    return 0;


errno Output

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