May 2012
Intermediate to advanced
679 pages
16h 56m
English
Normal operations with strings are:
Let us see how these operations are handled in C++.
Like any other variable we can use following statement to read the string from the console.
cin >> str1;
Only point to remember is that blank is used as a terminator in this case. Well, we can use the function gets() or getline() for reading strings with embedded blanks.
A simple statement
cout << str1;
is capable of writing a string. Here embedded blanks are not a problem. If there are embedded characters like ‘\n’ or ‘\t’, they will be treated appropriately. For example
cout << ...
Read now
Unlock full access