char arr[4];
cin>>arr;
cout<<arr;
cout<<sizeof(arr);
in this i allocated 4 spaces to arr…
and in input i entered 12 dgits
in output i got 12 gidits
but the size of the array remained same…why?
char arr[4];
cin>>arr;
cout<<arr;
cout<<sizeof(arr);
in this i allocated 4 spaces to arr…
and in input i entered 12 dgits
in output i got 12 gidits
but the size of the array remained same…why?
that is because the cout will only stop printing string when it discovers ‘\0’ character