Consider the following code:
int n;
if(!cin>>n)
{
cin.clear();
while(cin.get()!='\n')
continue;
}
cout<<n;
The output is:
0
Why there was no any prompt on the terminal for typing the input value for n? And why uninitialized n is set to 0 automatically?
Aucun commentaire:
Enregistrer un commentaire