Logo

Programming-Idioms

History of Idiom 169 > diff from v21 to v22

Edit summary for version 22 by programming-idioms.org:
[D] No need to declare s in code

Version 21

2018-02-05, 11:19:45

Version 22

2018-02-05, 11:19:55

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.

Extra Keywords
size
Extra Keywords
size
Code
string s;
size_t n = s.length;
Code
size_t n = s.length;
Comments bubble
n is the number of UTF-8 code units.
Comments bubble
n is the number of UTF-8 code units.