Search code examples
clinuxerror-handlingerrno

errno, strerror and Linux system calls


I can use strerror() to get text representation of errno value after using CRT functions, like fopen(). If I use open() Linux system call instead of CRT function, it also sets errno value when it fails. Is this correct to apply strerror() to this errno value? If not, is there some Linux system call, which does the same as strerror()?


Solution

  • Yes

    Yes

    In there is perror

    if (-1 == open(....))
    {
        perror("Could not open input file");
        exit(255)
    }