Logo

Programming-Idioms

History of Idiom 169 > diff from v77 to v78

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

Version 77

2020-04-30, 20:35:00

Version 78

2020-04-30, 20:35:09

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 <iterator>
#include <string>
Code
int n = std::distance(str.begin(), str.end());