What you’re doing (reading the value of an uninitialised variable) is undefined behaviour; anything can happen, from it appearing to work, to printing random values, to crashing, to buying pizza with your credit card.
More Related Contents:
- C++ while loop resetting variables?
- why this unexpected variable change happens? [closed]
- How do I store a value for later use?
- How do I print a double value with full precision using cout?
- uint8_t can’t be printed with cout
- How do I print out the contents of a vector?
- cout
- Variable initialization in C++
- ‘printf’ vs. ‘cout’ in C++
- dollar sign in variable name?
- C++ alignment when printing cout
- Difference between static, auto, global and local variable in the context of c and c++
- When do function-level static variables get allocated/initialized?
- c++ force std::cout flush (print to screen)
- C++ printing boolean, what is displayed?
- Why does streaming a char pointer to cout not print an address?
- How to make C++ cout not use scientific notation
- What happens to uninitialized variables? C++
- cout or printf which of the two has a faster execution speed C++?
- Why is std::cout not printing the correct value for my int8_t number?
- C++ int with preceding 0 changes entire value
- How to generate random variable names in C++ using macros?
- How to make cout behave as in binary mode?
- Does std::cout have a return value?
- What is the difference between cout, cerr, clog of iostream header in c++? When to use which one?
- Float formatting in C++
- generic way to print out variable name in c++
- Correctly over-loading a stringbuf to replace cout in a MATLAB mex file
- Why “cout” works weird for “unsigned char”?
- “cout” and “char address” [duplicate]