// Dave Goldsmith // Redwood High School // C++ Computer Programming // November 11, 1999 // C_str.cpp /* This program demonstrates the 'c_str' member function of the apstring class. This function is needed to convert an apstring object into a const char * for use with classes and functions that do not support apstrings. This example will write the phrase "This is some sample text" to a text file specified by the user. */ #include // Required for 'cin' and 'cout' #include // Required for 'ifstream' and 'ofstream' #include // Required for 'apstring' #include // Required for 'apstring' int main() { apstring filename; cout << "Enter a filename: "; getline(cin, filename); ofstream outputFile; outputFile.open(filename.c_str(), ios::out); outputFile << "This is some sample text"; outputFile.close(); return 0; }