Logo

Programming-Idioms

History of Idiom 169 > diff from v83 to v84

Edit summary for version 84 by WHS:
[C++] clarification in comment

Version 83

2020-12-24, 16:54:32

Version 84

2020-12-24, 16:54:53

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.

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.

Variables
n,s
Variables
n,s
Extra Keywords
size characters chars number runes
Extra Keywords
size characters chars number runes
Code
int n = s.size();
Code
int n = s.size();
Comments bubble
Returns byte count if s is of type std::string, for other widths use a different specialization of std::basic_string
Comments bubble
Returns byte count if s is of type std::string, for other character widths use a different specialization of std::basic_string
Doc URL
https://en.cppreference.com/w/cpp/string/basic_string/size
Doc URL
https://en.cppreference.com/w/cpp/string/basic_string/size