// Dave Goldsmith // Redwood High School // C++ Computer Programming // May 3, 2009 // AtoI.cpp /* This program demonstrates the use of the function 'atoi()' to convert a string (apstring) into an integer: int atoi ( const char * str ); */ #include // Required for 'cin' and 'cout' #include // Required for 'atoi' #include // Required for 'apstring' #include // Required for 'apstring' int main() { apstring word1 = "23"; apstring word2 = "6"; // Add word1 and word2 as strings cout << word1 + word2; cout << endl << endl; // Convert word1 and word2 to integers and add cout << atoi(word1.c_str()) + atoi(word2.c_str()); cout << endl << endl; return 0; }