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();