0

Inputs in a switch function.

I'm using cin to input a variable at the begging of the code, but when I use the function switch to evaluate that input deppending on the given value, the cin inside the "case" don't work, do I have to do something special on the swith functions to can input something? Thanks

21st Oct 2016, 3:49 PM
Roger Gomila
Roger Gomila - avatar
1 Resposta
+ 2
Here is the proper way to do it: int n; cin >> n; switch(n){ case 42: //do stuff break; //put more cases here }
21st Oct 2016, 6:10 PM
Zen
Zen - avatar