Hi,
may someone tell me why the following code doesn't work when i insert a char instead of an integer? What should i do?
Code:
#include <iostream>
using namespace std;
int main(){
    int x;
    while(true){cout<<"Insert an integer\n";
    if(cin>>x){
    cout<<"number is valid\n";
    break;}
    else{cout<<"number is invalid.Try again\n";cin.clear();}}
    system("pause");
    return 0;}