string I/O

The stream extraction operator (>>) is overloaded to support strings. The statements

string stringObject;
cin >> stringObject;

declare a string object and read a string from cin. Input is delimited by whitespace characters. When a delimiter is encountered, the input operation is terminated. Function getline also is overloaded for strings. Assuming string1 is a string, the statement

getline( cin, string1 );

reads a string from the keyboard into string1. Input is delimited by a newline (' '), so getLine can read a line of text into a string object. You can specify an alternate delimiter as the optional third argument to getline.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.68.197