获取线:未找到标识符
getline: identifier not found
我对getline()
有问题。
尝试了很多例子并阅读了其他解决方案,但这并没有解决我的问题。我还有信息'getline: identifier not found'
.
我包括 <stdio.h> <tchar.h> <iostream> <conio.h> <stdlib.h> <fstream>
,仍然一无所有。
#include "stdafx.h"
using namespace std;
int main(int argc, _TCHAR* argv[])
{
string line;
getline(cin, line);
cout << "You entered: " << line << endl;
}
我现在需要做什么?
我使用 Windows 7 64 位和 Visual Studio 2013。
习惯于简单地阅读您使用的语言功能的文档。
CPP偏好很清楚,std::getline
可能会在string
中找到。
#include <string>
这应该可以解决这个问题:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main(int argc, _TCHAR* argv[]){
string line;
getline(cin, line);
cout << "You entered: " << line << endl;
}
#include <string>
顺便说一下,"Murach's C++ Programming"教科书错误地指出getline()在iostream标头中(第71页),这可能会导致一些混淆。
你需要使用
#include "string"
阅读: 标准::获取线
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 使用指针从C++中的数组中获取最大值
- 如何获取std::result_of函数的返回类型
- 在C++中,是否可以基于给定的标识符创建基类的新实例,反之亦然
- 获取进程标识符始终返回 0
- 尝试使用类时获取标识符错误
- 获取窗口监视器的唯一标识符
- 从 Android 上的 c++ 获取唯一的设备标识符
- 编译器不喜欢我的类C++。获取未声明的标识符错误等
- 在给定的代码中获取错误(标识符未定义)
- 错误:标识符类名未定义?为我在文件中创建的所有类获取此内容
- 获取系统的唯一标识符(而不是MAC地址)
- 获取线:未找到标识符
- C++ Winapi - 获取目录(路径)标识符
- 如何获取计算机的唯一标识符
- 从HWND获取图标进程,进程名或其他进程标识符
- 通过接收钩子中的socket -标识符获取远程地址
- 在从书中复制的代码中获取未声明的标识符