Each errno has its own meaning. But it's just uncomfortable for people to read
trror() or error can replace the error number with a human-readable form.
#include <errno.h>
int main(void) {
FILE* fp;
if((fp = fopen("hello", "r") == 0){ // open missing file
printf("strerror(errno) : %s\n", strerror(errno));
perror("perror : ");
}
}
Output:
strerror(errno) : No such file or directory
perror : : No such file or directory
© 2024 OneMinuteCode. All rights reserved.