I'm doing an intensive course in C++ and I am the kind of person that likes and wants to understand everything under the sun otherwise I can't continue with my homework.
char anything[5]{};
cin >> anything;
cout << anything << endl;
I can write 'Hello' in the console and it's all good. Writing 'H' is good too, and 'Hel' is good too. But what shouldn't be right is writing 'Helloo' or 'Hellooo', and it works! The moment I write 'Helloooooooooooooooooooooooooooooooo' program crashes, which is ok. This does the same when using numbers.
Why is this happening? I'm using CodeLite.
To my understanding, if I write over 5 characters the program shouldn't allow it, but it does.
What's the explanation behind this?