// 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;
}
Code Example |
---|
Cpp :: split string on character vector C++ |
Cpp :: convert all characters in string to uppercase c++ |
Cpp :: What should main() return in C++? |
Cpp :: c++ return multiple values |
Cpp :: C++ Volume of a Sphere |
Cpp :: c++ std::sort |
Cpp :: c++ string contains |
Cpp :: C++ Swap 2 Variables Without Using 3rd Variable |
Cpp :: how to clear vector c++ |
Cpp :: c++ call method in same class |
Cpp :: C++ string initialization |
Cpp :: c++ segmented sieve |
Cpp :: push_back struct c++ |
Cpp :: Story of c++ |
Cpp :: string to char* |
Cpp :: c++ cast char to string |
Cpp :: binary representation c++ |
Cpp :: calloc c++ |
Cpp :: detect end of user input cpp |
Cpp :: cstring to string |
Cpp :: c++ code for bubble sort |
Cpp :: how to remove a index from a string in cpp |
Cpp :: sizeof operator in c++ |
Cpp :: C++ Vector Operation Add Element |
Cpp :: chudnovsky algorithm c++ |
Cpp :: how to delete a node c++ |
Cpp :: c++ add two char together |
Cpp :: how to make Dijkstra in c++ |
Cpp :: c++ in cmd |
Cpp :: insert in vector |