次のような文字列を含むファイルがあります
こんにちは私の名前はジョーです
元気にしてる?
いいですか?
そのファイルをそのまま出力しようとしているのですが、私のプログラムは「HellomynameisJoeHowAreyouDoing?Goodyou?」と出力しています。スペースと改行に問題があります。
int main (int argc, char* argv[])
{
index_table table1;
string word;
ifstream fileo;
fileo.open(argv[1]); //where this is the name of the file that is opened
vector<string> line;
while (fileo >> word){
line.push_back(word);
}
cout << word_table << endl;
for (int i=0; i < line.size(); i++)
{
if (find(line.begin(), line.end(), "\n") !=line.end())
cout << "ERRROR\n"; //My attempt at getting rid of new lines. Not working though.
cout << line[i];
}
fileo.close();
0 を返します。