Size of char array

char s3[10] = “hello”;
cout<<s3<<" "<<sizeof(s3)<<endl;

The output size for the above code is 10, why? And how to get the actual size of the array, that is 5 (for “hello”)?

hello @parikshitpanwar

because u have declared array of size 10.

use strlen function

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.