Here if i give namangarg as input it is able to print every char even though the size of char array is 5 only?

#include
using namespace std;
int main()
{
char ch[5];
cin>>ch;
cout<<ch;
return 0;
}

it depend on machine you are using if that extra memory is not given to anyone else it print whole string
but if it is allocated to someone else it give segmentation fault

in my case it is giving segmentation fault