/* * string3.cpp (sklar/05-apr-2009) * * this program demonstrates returning a string as the value of a function * */ #include #include using namespace std; /* * declare and define the printString() function to display the string * that is passed as an argument to the function */ void printString( string myString ) { cout << "your string = [" << myString << "]" << endl; } // end printString() /* * declare and define the initString() function to initialize the * value of the string */ string initString() { string localString; cout << "enter a string: "; getline( cin, localString ); return( localString ); } // end of initString() /** * define main() function */ int main() { // declare string as a local variable string myString; // initialize string myString = initString(); // now call function to print the string printString( myString ); } // end of main()