본문 바로가기

Lecture & Tip/C study[느뤼스터디]

Error 출력처리

Error 출력 처리 예제

[CODE]
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> extern int errno; int main(){ int fd; printf("ready errno : %d\n", errno); fd = open("ABC.c",O_RDONLY); if(fd==-1){ printf("after errno : %d\n", errno); printf("error : %s\n", strerror(errno)); }else{ printf("answer : %d\n"); } close(fd); }
[/CODE]