stat(“filename”,&st) が0を返せばファイル(ディレクトリ)が存在、それ以外なら存在しない。
#include <sys/stat.h> ... struct stat st; if( stat("filename",&st)==0 ){///// file exists cout << "file exist." << endl; }