Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - If the int variable in C++ doesn't give a specific value, why is cout a definite number when it is output?
If the int variable in C++ doesn't give a specific value, why is cout a definite number when it is output?
When declaring C/C++ variables, most variables can be initialized or not. Some of these variables are automatically initialized to 0 or NULL when uninitialized, and the details may vary from compiler to compiler. Usually, the values of variables such as int, double and char are indefinite when uninitialized, while arrays and strings may be 0 or NULL or indefinite. So it's not surprising that you have this situation. Because of this, C/C++ stipulates that variables must be defined (initialized) before use. "Uncertain" or "random" here does not mean that you get different results once you run it, but that one result is on this machine and the other result is on another machine; Or this boot operation is the result and another boot operation may be another result. ...