小编Soh*_*el 的帖子

什么是 cin.peek,它有什么作用?

#include <iostream>
using namespace std;
int main() 
{
//Declare data types
int NumChild; //var
const int BaseFee = 150; //constant

//Welcome + Instructions for users
cout << "Welcome to IOU Secondary School" << endl <<endl<< "How many 
children are attending the school this year? "<<endl;

//Nested IF-ELSE (error checking)
if (cin >> NumChild)/

    {

        //do not accept any non-integer values
        if (cin.peek() == EOF|| cin.peek() == '\n' )
        {

        }
        else
        { 

            cout <<endl<< "Error: enter a whole number."<<endl<< "The …
Run Code Online (Sandbox Code Playgroud)

c++ iostream cin

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

c++ ×1

cin ×1

iostream ×1