Both size() and length() returns the size of the string. But only one option can be selected. How is that?
Q7. String STL 01
hey @sushil_d_loser As per the documentation of c++(https://en.cppreference.com/w/cpp/string/basic_string), these are just synonyms. size() is there to be consistent with other STL containers (like vector, map, etc.) and length() is to be consistent with most peoples’ intuitive notion of character strings. People usually talk about a word, sentence or paragraph’s length, not its size, so length() is there to make things more readable. So length length is often used with strings.