+ 23

Getting 2 inputs from user in Code playground.

I was testing the code in C++ course that encountered a problem. The program takes 2 input and then print them to cout. When I submit only one integer, the second one will be '8'. And when I submit no input the first one will be '0' and second one again '8'. Is their any default value rule or they are just garbage? https://code.sololearn.com/cqhzABJMew4u/?ref=app

29th May 2018, 9:05 PM
Amir
Amir - avatar
4 ответов
+ 5
Initialize the variables, otherwise you risk having garbage value. int a {0}, b {0}; I can't explain the reason behind the value for variable <b> which always be 8 while being uninitialized, but in the following discussion you can find good explanation of how variables value are initialized: https://www.sololearn.com/Discuss/1128723/?ref=app Hth, cmiiw
29th May 2018, 9:43 PM
Ipang
+ 22
Toni Isotalo : it's ok when I submit 2 numbers seperated with an Enter.
29th May 2018, 9:43 PM
Amir
Amir - avatar
+ 3
You can't take multiple inputs in sololearn.
29th May 2018, 9:34 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
some problem with sololearn IDE
8th Jun 2018, 2:10 PM
Zeeshan Ahmad
Zeeshan Ahmad - avatar