我不能接受getline
I cannot cin with getline
int itrtn;
cout << "How many iterations? ";
cin >> itrtn;
double leftx, rightx,midx,midy;
cout << "Enter the endpoints of the interval containing the root: ";
cin >> leftx>>rightx;
cout<<"Enter the polynomial coefficients, ascending in degree: ";
string degree;
getline(cin,degree); // gets an entire line of input
istringstream fake_keyboard(degree); // use fake keyboard like cin
vector<double> coefficients;
double coeff;
while (fake_keyboard >> coeff) coefficients.push_back(coeff);
这是我的代码,但我不能在第三个问题上与 Getline 合作。编译器只是跳过此步骤并将向量零设置为默认值
在调用之前使用虚拟getchar()
或cin.get()
消耗额外的n
getline()
。
cin >> leftx>>rightx;
cin.get(); //consume the 'n' of previous input.
cout<<"Enter the polynomial coefficients, ascending in degree: ";
相关文章:
- "xshared_expression"不能接受xfunction表达式
- 为什么此参数包不能接受函数指针?
- istringstream-function string_to_int不能接受C-STR,为什么
- 为什么 std:map 不能接受指针作为键值?
- C++:强制实施函数,使其不能接受按值传递的任何参数
- 我不能接受getline
- 为什么我的 select() 不能接受新客户端?
- 为什么"auto"在推导返回值时不能接受大括号的初始化列表?
- 什么不能接受字符串向量并用 offest 和 assigmnet 运算符替换任何字符串的字符?
- 为什么 std::function 不能接受推导类型作为其模板参数
- "官方"CUDA 减少功能不能接受某些数字?
- 枚举类型不能接受 CIN 命令
- 为什么 std::map::insert 不能接受键和值而不是 std::p air?
- 为什么函数中的局部数组不能接受一个不稳定的参数?在c++中
- Getline不能在cin.clear后获取某些字符
- 不能接受值对象- c++
- 为什么类成员函数不能接受与其类相同类型的多个参数
- 为什么cin.getline()不能工作(c++)
- Getline()不能打开文本文件
- 为什么 std::istream::getline 不能在 std::string 上运行