Logo

Programming-Idioms

History of Idiom 169 > diff from v63 to v64

Edit summary for version 64 by Blooser:
New Cpp implementation by user [Blooser]

Version 63

2019-09-26, 20:15:16

Version 64

2019-09-26, 22:03:03

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
std::cout<<std::distance(str.begin(), str.end());