For instance I would expect some kind of error message while or after executing the following code as shown:
#include <iostream>
using namespace std;
int main(){
char name[10];
cout << "Who are you?\n Enter your name: ";
cin >> name;
cout << "You are "<< name << "\n";
return 0;
}
and compiling and executing, for instance with g++ -Wall test.cpp -o test.x and executing test.x
Enter name: abcdefghijklmnopqrstuvyz
so the system reply back:
you are: abcdefghijklmnopqrstuvyz
So created an array of type char with 10 places but it could store much more than 10. So the program went on more memory spaces than what I would expect. I was wondering why the compiler (in this case g++) allows that ?