previous
|
start
|
next
Character Arrays
Generally it is best to avoid the use of character arrays - the string class is safer and far more convenient.
Occasionally you need to convert a
string
into a character array to call a function that was written before the
string
class was invented.
Example: to convert a character array containing digits into its integer value.
int atoi(const char s[])
Use the
c_str
member function to convert a
string
into a character array.
string year = "1999"; int y = atoi(year.c_str());
previous
|
start
|
next