// 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 <cstring>
strlen(str);
#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;
}
str txt = 'sdfsfsa'
cout << txt.length();
Code Example |
---|
Cpp :: c++ cout without include iostream |
Cpp :: setw c++ |
Cpp :: C++ float and double Different Precisions For Different Variables |
Cpp :: c preprocessor operations |
Cpp :: find element in vector |
Cpp :: Search Insert Position leetcode solution in cpp |
Cpp :: c++ builder |
Cpp :: automatic legend matlab |
Cpp :: struct c++ |
Cpp :: position of max element in vector c++ |
Cpp :: c++ string slicing |
Cpp :: demonstrate constructor |
Cpp :: check if a key is in map c++ |
Cpp :: c++ preprocessor operations |
Cpp :: attention nlp |
Cpp :: check even or odd c++ |
Cpp :: C++ String Compare Example |
Cpp :: c++ template |
Cpp :: tuple vector c++ |
Cpp :: preorder |
Cpp :: Bucket and Water Flow codechef solution in c++ |
Cpp :: cpp gui |
Cpp :: loop execution descending order in c++ |
Cpp :: c++ unittest in ros |
Cpp :: c++ set intersection |
Cpp :: how to increase array memory in c++ |
Cpp :: c++ insert hashmap |
Cpp :: async multi thread |
Cpp :: split string in c++ |
Cpp :: if not c++ |