1.

String Functions

Answer»
  • append function
string firstName = "Ramesh ";
string lastName = "Babu";
string fullName = firstName.append(lastName);
cout << fullName;

This function concatenates one string after another string. The output of the above code will be: Ramesh Babu

You can also change any individual character of a string in C++.

string variable1 = "Hello World";
variable1[1] = 'i';
cout << variable1;
  • length function
string variable1 = "Find my length";
cout << "The length of the string is: " << variable1.length();

It returns the length of the string as an integer.




Discussion

No Comment Found