Answers for "how to get lenght of string in c++"

C++
2

how to get string length in c++

#include <iostream>
#include <string>

int main()
{
  string str = "iftee";
  
  //method 1: using length() function
  int len = str.length();
  cout << "The String Length: " << len << endl;
  
  //method 2: using size() function
  int len2 = str.size();
  cout << "The String Length: " << len2 << endl;
  
  return 0;
}
Posted by: Guest on September-09-2020
0

how to get string length in c++

string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout << "The length of the txt 
  string is: " << txt.length();
Posted by: Guest on October-31-2021

Browse Popular Code Answers by Language