jeudi 31 mars 2016

numeric_limits only in the first input he wait for second input

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;

int main() 
{   
    int num, num2;  
    do  
    {       
        cout << "Enter number:";
        cin.clear();        
        cin.ignore(numeric_limits<streamsize>::max(), '\n');
        cin.clear();        
        cin >> num;     
    }
    while (!(num > 1000 && num < 9999));
    cout << num << endl;    
    return 0; 
}

Aucun commentaire:

Enregistrer un commentaire