2013-02-06 47 views
0

我的代碼應該打開100個文件(並對它們做一些處理),並在路徑中使用下列索引: 「c:\ Naprzeme \ NAPRZ100.IN」下一個是「c:\ Naprzeme \ NAPRZ101」。 IN」等:字符串變量打開文件

for (int as=100;as<159;as++){ 
    ostringstream ss; 
    ss << as; 
    string cherk = ss.str(); 
string supremeCounter = "c:\\Naprzeme\\NAPRZ"+cherk+".IN"; 
fstream infile(supremeCounter); 
//....other code here 
} 

fstream infile(supremeCounter)返回錯誤

28 31 C:\Users\talent\Documents\File.cpp [Error] no matching 
function for call to  'std::basic_fstream<char>::basic_fstream(std::string&)' 
candidates are: //(here some libs)... 

回答

2

fstream infile(supremeCounter.c_str());