string arr[]={"sdfsf",
"sdfete","dfgsh"};
cout<< sizeof(arr)
output is 24 in the given statement
string arr[]={"sdfsf",
"sdfete","dfgsh"};
cout<< sizeof(arr)
output is 24 in the given statement
sizeof() is a compile-time expression giving you the size of a type or a variable’s type. It doesn’t care about the value of the variable.
Exactly what size you get depends on how the string class is implemented. You might also get a different size if you compile the program in release mode.
On my PC i get sizeof(Arr) to be 72 for same arr[].
sizeof() doesnt consider the value, but returns size of the variable in bytes.
Hope this clears your doubt.
Mark it resolved if doubt is cleared.
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.