[프로그래밍/C] 파일 존재 유무 확인하기(how to check existence of file on C,linux)
굳이 파일이 존재 하는지 확인을 하려면 1. fopen()의 리턴값을 확인한다.FILE *fopen(const char *path, const char *mode);FILE 포인터로 리턴을 하는데 open 실패시 NULL을 리턴하며, errno에 에러를 기록함. 2. access()로 확인한다.int access(const char *pathname, int mode);리턴값을 바로 확인하면 됨. 3. fstat()의 리턴값을 확인한다int fstat(int filedes, struct stat *buf);리턴값을 바로 확인하면 됨. 구차니즘을 털고 2008.01.06일 테스트#include #include #include #include int main(){ int ret = 0; clock_t bef..