// string::length
#include <iostream>
#include <string>
int main ()
{
std::string str ("Test string");
std::cout << "The size of str is " << str.length() << " bytes.
";
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char ary[] = "Welcome to Softhunt.net";
cout << "Length of String = " << strlen(ary)<<endl;
return 0;
}
str.length();
let str ="Hello World! "
console.log(str.length);
//17
// string::length
#include <iostream>
#include <string>
int main ()
{
std::string str ("Test string ");
std::cout << "The size of str is " << str.length() << " bytes.
";
return 0;
}
//The size of str is 18 bytes.
string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cout << "The length of the txt
string is: " << txt.length();
string str ="hello world";
//different ways to find length of a string:
str.length();
str.size();
//me
myStr.length(); //method 1
myStr.size(); //method 2
#include <string>
#include <iostream>
int main()
{
std::string s(21, '*');
std::cout << s << std::endl;
return 0;
}
#include <iostream>
using namespace std;
int main() {
string str = "Viet Nam";
cout << "String Length = " << str.size();
// you can also use str.length()
return 0;
}