August 2001
Beginner
482 pages
10h 52m
English
A string is a series of characters. The only strings you've seen until now have been unnamed string constants used in cout statements, such as |
cout << "hello world.\n";
In C++, a string is an array of chars ending with a null character. You can declare and initialize a string just as you would any other array. For example:
char Greeting[] = { 'H', 'e', 'l', 'l', 'o', ' ',
'W','o','r','l','d', '\0' };
The last character, '\0', is the null character, which many C++ functions recognize as the terminator for a string. Although this character-by-character approach works, it is difficult to type and admits too many opportunities for ...
Read now
Unlock full access