Logo

Programming-Idioms

History of Idiom 169 > diff from v23 to v24

Edit summary for version 24 by programming-idioms.org:
[Cpp] Mess

Version 23

2018-02-14, 15:11:54

Version 24

2018-02-14, 22:18:33

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
Imports
import <string>
Imports
import <string>
Code
std::string x = "string len";
int xlen = x.length();
Code
int n = s.length();
Comments bubble
1. make new string
2. x.length() returns string length
Comments bubble
s is a std::string
Doc URL
http://www.cplusplus.com/reference/string/string/length/
Doc URL
http://www.cplusplus.com/reference/string/string/length/