+ 3
What Size Does A String Variable Occupy ?
If I declare a string name and do not assign anything to it , the sizeof operator returns size of 32 bytes , but what if I store a string greater than 32 characters in it ? Would it write the extra characters in some unreserved memory ? https://code.sololearn.com/c35qYPDSXOfz/?ref=app
2 odpowiedzi
+ 1
string has internally array of chars which is resized every time you add element which goes beyond reserved memory. So string memory depends on number of elements it stores.
+ 2
https://code.sololearn.com/cMj3hUOxo0ra/?ref=app
better to use this