Answers for "find the length of a string in c++"

C++
0

how to get c++ string length

string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout << "The length of the txt 
  string is: " << txt.length(); 
  
//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(). 
//It is completely up to you if you want to use length() or size():
  
  string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout << "The length of the txt string is: " << txt.size();
Posted by: Guest on August-20-2021

Code answers related to "find the length of a string in c++"

Browse Popular Code Answers by Language