#include#include using namespace std; int main() { string s = "hello"; cout << "The size of string s is: " << s.size() << endl; return 0; }
The size of string s is: 5
#include#include using namespace std; int main() { string s = "quick brown fox jumps"; cout << "The size of string s is: " << s.size() << endl; return 0; }
The size of string s is: 22In this example, the size() function is used to find the number of characters present in the string "quick brown fox jumps". The output displays the size of the string which is 22. Package library: Standard library (stream header and string header)