how to get c 2b 2b string length

Solutions on MaxInterview for how to get c 2b 2b string length by the best coders in the world

showing results for - "how to get c 2b 2b string length"
Nicole
29 Nov 2019
1
2  string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3cout << "The length of the txt 
4  string is: " << txt.length(); 
5  
6//Tip: You might see some C++ programs that use the size() function to get the length of a string. This is just an alias of length(). 
7//It is completely up to you if you want to use length() or size():
8  
9  string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
10cout << "The length of the txt string is: " << txt.size();