Hi, I'm new to c++. I was playing around with char arrays but i somehow end up with strange characters in my final char array when i try to join 2 together(example ╝■(alfred nathan). When i change the array size from 20 to 10, I get no problems. Some help here please! Thanks in advance for any help that i can get :)
Yes. It might happen to contain zero values, which will be interpreted as an empty string, but really it could contain anything at all, just whatever happens to be at that memory location from some previous use. The answer, as I think you figured out, is to give it an initial value , perhaps like this,
char name[40] = "";
(if you use c++ std::string, that is automatically initialised as an empty string).