2014-01-07 22 views

回答

3
bool file_does_exist(const std::string &filename) { 
    return std::ifstream(filename); 
} 
0

這個問題不太清楚,但你的意思是?

std::ifstream file("file_name.ext"); 
if (file) 
{ 
    read_from(file); 
} 
1

你可以簡單地打開文件進行讀取

std::fstream fs; 
fs.open ("test.txt", std::fstream::in); 

,然後檢查,如果一切都還好吧

if(fs.good()) 
    //... 
相關問題