방법1 (best)
#include <unistd.h> if( access( fname, F_OK ) != -1 ) { // file exists } else { // file doesn't exist }
방법2
int exists(const char *fname) { FILE *file; if ((file = fopen(fname, "r"))) { fclose(file); return 1; } return 0; }
방법3
int file_exist (char *filename) { struct stat buffer; return (stat (filename, &buffer) == 0); } if (file_exist ("myfile.txt")) { printf ("It exists\n"); }
Designed by sketchbooks.co.kr / sketchbook5 board skin
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5