Just as a heads up, some debuggers (such as Visual Studio) will complain if you use uninitialized variables.
Just as a heads up, some debuggers (such as Visual Studio) will complain if you use uninitialized variables.
Actually, the debugger just catches the crash and identifies that it happend through an uninitialized variable - this is done by filling local stack-based variables with a pattern just like I described above, and when the data is being used as a pointer/index, it is detected as a "uninitialized data" error, rather than a random "got outside valid memory".
--
Mats
If you want to put it that way, sure.
There are always several ways to catch uninitialized variables.
Having a debugger do it for you is nice, I think.
Oh and some compiler will warn you if you try to use an uninitialized variable. I'm guessing GCC does and I know VC++ does.
Remember always to put your compiler warnings to maximum!