+ 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
4 Answers
+ 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
+ 22
Toni Isotalo : it's ok when I submit 2 numbers seperated with an Enter.
+ 3
You can't take multiple inputs in sololearn.
+ 2
some problem with sololearn IDE