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
Post a Comment