Calculate Characters in a String in C++ with Example

The string.h or cstring files must be included in programs that use standard functions to manipulate C strings. These header files grant access to the functionality of the C string library and are to be distinguished from the string header file that defines the string class. Each compiler offers additional header files for platform dependent functionalities. These may be graphics libraries or database interfaces.

string program calucalte the name in C++

#include <iostream> #include <string> using namespace std; int main() { string prompt("What is your name: "), name, line( 40, '-'), total = "Hello "; cout << prompt; getline( cin, name); total = total + name; cout << line << endl << total << endl; cout << " Your name is " << name.length() << " characters long!" << endl; cout << line << endl; return 0; }