islouis
Junior Member level 1
c++ cin default
Dear Sir:
May i know how can i use the default int value, when user didnt enter any value and just press enter?
I have used the following code but didnt quit work, assume the default value is int 50, Thanks for any help!
char Chr;
int number;
number=cin.get();
if (Chr==10) // When press enter without a value Chr=10?
number=50;
else
number=Chr;
cout << number;
Dear Sir:
May i know how can i use the default int value, when user didnt enter any value and just press enter?
I have used the following code but didnt quit work, assume the default value is int 50, Thanks for any help!
char Chr;
int number;
number=cin.get();
if (Chr==10) // When press enter without a value Chr=10?
number=50;
else
number=Chr;
cout << number;