程序在终止循环后未接受输入

时间:2019-10-17 13:31:57

标签: c++

我正在尝试制作一个计算n个整数之和的程序。但是,当我尝试运行该程序时,它不会接受<uses-sdk tools:overrideLibrary="microsoft intune package name" /> 的输入。

val2

1 个答案:

答案 0 :(得分:0)

包括标题

#include <limits>

以及此代码段之前

cout << "Enter the number to find the sum of integers: ";

std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );

问题在于,输入符号'|'后,输入流处于错误状态,您需要跳过输入缓冲区中的非数字符号。