+ 1
Why we get garbage value in output of program in C++?
Sometimes we're doing problems and everything would be right even though we got garbage value.
2 Respuestas
+ 2
A garbage value occurs when you allocate a memory for your variable, but you don't assign a value to your variable. The memory of the variable may still have a value from the previous program. We called the value garbage value.
This is an undefined behavior, which is, yeah, the behavior C++ does not define. Such thing will cause ANYTHING to your machine, e.g., crash.
+ 1
CarrieForle gives a perfect answer. Just one nitpick -- modern operating systems will never give you "a value from the previous program" since that is a security risk. So all garbage you see is your own.