-2

なぜこのコードが機能しないのですか?エラーメッセージ:main.cpp:147:5:error:expected';' 'fin'の前</p>

   string file;
    ifstream fin;
    fin.clear();

    cout << "\n\t--------------------------------Enter Person's name then surname to display------";
    cin>>file;

    file +=".txt"
    fin.open(file.c_str());

    char word[50];
    fin>>word;
    while(fin.good()){


        cout << word << " ";
        fin >> word;
    }


    system("pause");
    return 0;

}
4

3 に答える 3

2

この行の最後にセミコロンが必要です。

file +=".txt"

これでエラーが修正されます。

于 2013-03-24T00:32:19.697 に答える
1

さてあなたは;後を逃していますfile +=".txt"

string file;
ifstream fin;
fin.clear();

cout << "\n\t--------------------------------Enter Person's name then surname to display------";
cin>>file;

file +=".txt";
fin.open(file.c_str());

char word[50];
fin>>word;
while(fin.good()){


    cout << word << " ";
    fin >> word;
}


system("pause");
return 0;

}

于 2013-03-24T00:32:48.890 に答える
1

下の行にセミコロンがありません。

file +=".txt"   <-------- put a semi colon HERE
    fin.open(file.c_str());
于 2013-03-24T00:44:00.983 に答える