C++ C+中iostream中未定义的getlines+;
这是我的密码: 出于某种原因,C++ C+中iostream中未定义的getlines+;,c++,visual-studio,getline,C++,Visual Studio,Getline,这是我的密码: 出于某种原因,getline表示未定义。我的教授告诉我,我可能使用的是一个较老的C++版本,但我没有线索如何检查。 我正在使用Visual Studio Ultimate 2013。请救救我 提前谢谢 顺便说一句:我不介意代码中任何与getline无关的错误。代码不完整,但当getline未定义时,我无法测试它 #include <iostream> using namespace std; int main() { string concatenated
getline
表示未定义。我的教授告诉我,我可能使用的是一个较老的C++版本,但我没有线索如何检查。
我正在使用Visual Studio Ultimate 2013。请救救我
提前谢谢
顺便说一句:我不介意代码中任何与getline
无关的错误。代码不完整,但当getline
未定义时,我无法测试它
#include <iostream>
using namespace std;
int main()
{
string concatenatedLines;
getline(cin, concatenatedLines);
if (!cin)
{ // C++ can overwrite conversion operator... cin is being converter into a boolean operator. It is FALSE if you attempted to read and there's nothing there.
return 1;
}
// START OF MISSING CODE *-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=
//
int numberOfLines = 1;
int stat = 0;
string line;
string space = " ";
while (stat == 0)
{
getline(cin, line);
if (!cin) stat = 1;
else{
concatenatedLines = line + space + concatenatedLines;
numberOfLines++;
}
}
//
// END OF MISSING CODE *-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=
cout << concatenatedLines << endl;
//endl = end of the line - declared in the standart library
cout << concatenatedLines << endl;
return 0;
}
#包括
使用名称空间std;
int main()
{
字符串连接行;
getline(cin,连接线);
如果(!cin)
{//C++可以覆盖转换运算符…CIN正在转换成布尔运算符。如果你试图读取,那么它就不存在了。
返回1;
}
//缺失代码的开始*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=
//
int numberOfLines=1;
int stat=0;
弦线;
字符串空格=”;
while(stat==0)
{
getline(cin,line);
如果(!cin)stat=1;
否则{
连接线=线+空间+连接线;
numberOfLines++;
}
}
//
//缺失代码的结尾*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=*-=
cout您还需要包含
标题。包含字符串
标题。