1// string::length
2#include <iostream>
3#include <string>
4
5int main ()
6{
7 std::string str ("Test string");
8 std::cout << "The size of str is " << str.length() << " bytes.\n";
9 return 0;
10}
1#include <string>
2#include <iostream>
3
4int main()
5{
6 std::string s(21, '*');
7
8 std::cout << s << std::endl;
9
10 return 0;
11}
12
1string str ="hello world";
2//different ways to find length of a string:
3str.length();
4str.size();
5
1// string::size
2#include <iostream>
3#include <string>
4
5int main ()
6{
7 std::string str ("Test string");
8 std::cout << "The size of str is " << str.size() << " bytes.\n";
9 return 0;
10}