Characters, Strings, and the cstring library

String I/O:

Reading strings: get and getline


 char greeting[15], name[10], other[20];

 cin.getline(greeting,15);    // gets input into the greeting array
 cin.get(name,10,'.');        // gets input into the name array
 cin.getline(other,20);       // gets input into the other array

Suppose that the data on the input stream (i.e. typed onto the keyboard, for instance) is:

 Hello, World
 Joe Smith.  He says hello.
At this point, the contents of each string are:
 greeting:  "Hello, World"
 name:      "Joe Smith"
 other:     ".  He says hello."
Here's an example illustrating some different calls that read strings

The standard C string library:

The standard string library in C is called cstring. To use it, we place the appropriate #include statement in a code file:
 #include <cstring>

This string library contains many useful string manipulation functions. These are all for use with C-style strings. A few of the more commonly used ones are mentioned here. (The textbook contains more detail in chapter 10)