编译提示的问题
[code=C/C++][/code]
//该程序完成一项任务:把一段文字输出到文本文挡
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
string quote, speaker;
cout << "enter a quotation:\n";
getline(cin, quote);
//prompt the user for the quotation's author
cout << "enter the person to whom this quote is attributed:\n";
getline(cin, speaker);
//repet the quotation to the user
cout << "the following has been received...\n\n" << quote << "\n-" << speaker "\n\n";
//write the data to the file
//declaring a file object
ofstream fileOutput("quote.txt", ios::app);
if (fileOutput.is_open()){
fileOutput << quote << "-" << speaker << "\n";
fileOutput.close();
//print a message
cout << "the data has been written to the file!\n";
} else {
cout << "the file could not be opened!\n";
return 1;
}
//wait for the user to press enter or return
cout << "press enter or return to continue.\n";
cin.get();
return 0;
}
编译时提示 error C2143: syntax error : missing ';' before 'string'
Error executing cl.exe.
quote3.obj - 1 error(s), 0 warning(s)
请问各位高人,我怎么也找不出那个错误
[解决办法]
cout << "the following has been received...\n\n" << quote << "\n-" << speaker << "\n\n";
[解决办法]
cout << "the following has been received...\n\n" << quote << "\n-" << speaker << "\n\n";
[解决办法]
楼上不能这么说。解决问题不问分多不多。