获取线函数未定义错误。无法在字符串中保存可验证的内容
getline function is not defined error.Can't hold the veriable in string
#include <iostream>
#include <string>
using namespace std;
int main()
{
string message;
cout << "Type your message: ";
cin.ignore();
getline(cin, message);
return 0;
}
它给出了getline函数未定义的错误。
我只想将写入的字符串保存在可验证的消息中。
这是图片
"...string, stdafx.h 和 iostream...">:"stdafx.h"
必须是第一行。编译器将忽略它上面的所有内容(<string>
将不包括在内,因此编译器将抱怨:getline not found
(。
我不知道你想做什么,但下面的代码将编译并运行:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
string message;
cout << "Type your message: ";
cin.ignore();
getline( cin, message );
return 0;
}
相关文章:
- 将字符指针十六进制转换为字符串并保存在文本文件C++中
- C++.我想将更改后的特定字符行保存在字符串中
- 保存名称或字符串
- C++ 将地址保存为字符串的向量转换为新的向量
- C++读取大文件并将其保存到字符串中,然后删除特定的随机单词
- C++以尽可能快的速度逐行将字符串保存到文件中
- 如何在c++中将字符串中的所有数字保存到多维数组中
- C++我应该用什么来保存格式化为字符串变量(如sprintf())的文件
- 使用 ctime 保存新时间点会覆盖旧字符串?
- 如何将 std::string 作为构造函数参数传递,并将其保存的 C 字符串存储在 void 指针中?
- 获取线未将所有字符保存到字符串
- 获取线函数未定义错误。无法在字符串中保存可验证的内容
- 如何将字符串保存在最长的常见子序列递归算法中
- 如果我不将预先编写的字符串保存到变量,它还在内存中吗?
- 声明变量以保存字符串列表时的内存分配
- 为什么 boost::any 不保存字符串文字
- 如何保存字符串并按顺序读取/写入它们
- 如何从编辑框中保存字符串以及如何使用复选框禁用编辑框
- 如何在枚举中保存字符串
- 使用next_permutation函数后如何保存字符串/整数