#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line,line2;
char dude[20];
cin.getline(dude,20);
fstream myfile ("example.txt",ios::in);
if(!myfile)
{
cout<<"Not Found! ";
system("pause");
}
while (!myfile.eof())
{
getline(myfile,line);
cout<<line;
}
myfile.close();
exit(0);
}
これは動作しますが、私はこれを行う場合は宣言しました。 [std :: basic_istream :: getline(std :: string &、int)への呼び出しで一致する関数がありません ' なぜですか?は
*「WHY?」*「文字列」と「int」をとる 'getline()'のオーバーロードがないためです。エラーメッセージのどの部分がわかりにくいですか? –
コードには、while(!myfile.eof())のような欠陥があります。 –