C++ cout fresh array gibberish -


when "cout" empty array, gibberish. why?

int main() { char test[10]; cout << test; return 0; } 

...returns unicode blather. easy answer i'm sure.

since didn't initialize array got garbage value (test[0] printing out).

initialize it:

int main() {      char test[10] = {};     cout << test;     return 0; } 

just note:

just because compilers initialize stuff (like compilers initialize ints, floats etc., @ 0) not case, , can garbage value otherwise.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -