Search notes:

libc: perror

// #include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int main() {

  int fd = open("/this/file/does/not/exist", O_RDONLY);

  if (fd == -1) {
    // error
    perror("Could not open file, error is");
    exit (1);
  
  }

}
Github repository about-libc, path: /functions/error/perror.c
The output of this program is, if indeed there is no such file:
Could not open file, error is: No such file or directory

See also

The Standard C Library

Index