When I was messing around I just made this program to see what would happen-
and I got some strange number. Why is this?Code:#include <iostream> int main() { int x; std::cout << x; return 0; }
When I was messing around I just made this program to see what would happen-
and I got some strange number. Why is this?Code:#include <iostream> int main() { int x; std::cout << x; return 0; }
A variable will always hold a value, in your case it's just undefined which is why you see garbage.
The data you are seeing is what was left in that memory chunk by whatever wrote there before.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
if it hasn't been written to since you have turned on your computer does it equal 0?
french, not necessarily (at least I don't think so).
The only variables that are guaranteed to be initialized to 0 are variables and objects that are not on the stack or heap (unless another value is explicitly specified).
For instance, globals are guaranteed to be initialized to 0.