Wednesday, August 1, 2012

The Complete Reference C++(Third Edition)


The Complete Reference C++(Third Edition)


About the Author…
Herb Schildt is the leading authority on C and
C++ and a best-selling author whose books
have sold more than 1.5 million copies. His
acclaimed C and C++books include Teach
Yourself C, C++ from the Ground Up, Teach
Yourself C++, C++: The Complete Reference,
Borland C++: The Complete Reference, and C++
Programmer's Reference to name a few..


Arrays of Strings
It is not uncommon in programming to use an array of strings. For example, th
processor to a database may verify user commands against an array of valid
commands. To create an array of null-terminated strings, use a two-dimension
character array. The size of the left index determines the number of strings and
of the right index specifies the maximum length of each string. The following c
declares an array of 30 strings, each with a maximum length of 79 characters
char str_array[30][80];
It is easy to access an individual string: You simply specify only the left ind
example, the following statement calls gets() with the third string instr_array
gets(str_array[2]);
The preceding statement is functionally equivalent to
gets(&str_array[2][0]);
but the first of the two forms is much more common in professionally written
C/C++ code.







No comments:

Post a Comment