+ 4
What just happened
I wast trying to do a brute force in c++ and this happened https://code.sololearn.com/ceJosWMarl8w/?ref=app Can someone explain me this?
6 Réponses
+ 5
Arthur you have not done initialization of all three int variable of for loop...also your test should be as below :
x[i]+x[i2]+x[i3]
+ 2
Ketan Lalcheta Yeah, i totally forgot this...
Do you have any idea about why this happened?
+ 2
Ketan Lalcheta Noww its showing no output...
+ 1
Arthur any uninitialized variable, if not static, gets random value by default.. and additionally, you were not adding char from char array but int only to char
+ 1
Ketan Lalcheta [not to distract, just trivia]
Uninitialized variables get whatever is in memory at the time. This is not necessarily random, and may even be usefully deterministic.
It's still abnormal as an initializer though. :)
0
Damn!!