#include <sys/stat.h>#include <fstream>using namespace std;char* fileName = "file.txt";//first methodifstream infile(fileName);bool exists1 = infile.good();//second methodstruct stat buffer;bool exists2 = stat(fileName, &buffer) == 0;