Logo

Programming-Idioms

History of Idiom 169 > diff from v76 to v77

Edit summary for version 77 by programming-idioms.org:
Admin deletes impl 2809: Wrong result "été"->5

Version 76

2020-04-30, 20:26:28

Version 77

2020-04-30, 20:35:00

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration
Extra Keywords
size characters chars number runes
Extra Keywords
size characters chars number runes
Imports
#include <string>
Code
auto n = s.size();
Comments bubble
s.size() and s.length() is the same
Doc URL
https://en.cppreference.com/w/cpp/string/basic_string/size