在 C++ 年的 iostream 中未定义的获取线
getlines undefined in iostream in C++
这是我的代码:出于某种原因,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;
}
您还需要包含<string>
标头。
相关文章:
- 获取对function_name的未定义引用
- 为不应该获得未定义行为的内容获取未定义的行为
- Armadillo正在为共享的lapack库获取未定义的参考
- 获取未定义的符号:尝试使用Clang地址清理器时__asan_memset
- 获取作为类变量的 Deque 大小时未定义的行为
- 获取线函数未定义错误。无法在字符串中保存可验证的内容
- 获取未初始化对象成员的地址是否定义良好?
- C++程序调用 C 函数 在 g++ 链接期间获取未定义的引用
- 尝试编写进程内存并获取用户定义的文字运算符未找到
- 获取错误:未定义对函数 Android NDK 的引用
- 获取数组/向量末尾地址的未定义行为
- 在 C++ 年的 iostream 中未定义的获取线
- wxWidget获取许多未定义的引用
- 在给定的代码中获取错误(标识符未定义)
- 获取函数运算符<未定义的引用
- 错误:标识符类名未定义?为我在文件中创建的所有类获取此内容
- C++ 获取未定义的符号错误
- 正在尝试将C++绑定到Haskell:获取未定义的引用错误
- 获取未定义的引用错误
- 静态结构成员获取"未定义的引用"。不知道为什么