+ 1
Difference between string length and string size
What is the difference between string length and string size?
2 Answers
+ 3
if you do:
string s = "abc";
int size = s.size();
int len = s.length();
cout << size << len;
you will still get 3 in "size" integer and the same in "len" integer.
they can do practically same thing but it's more recommend to do length() since it's more readable and size() is used in vectors
+ 1
@Jamie So basically string size also includes null character \0 correct?