/* * string1.cpp (sklar/05-apr-2009) * * this program demonstrates passing a string to 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() /** * define main() function */ int main() { // declare string as a local variable string myString; string string2; // initialize string cout << "enter a string: "; getline( cin, myString ); cout << "enter another string: "; getline( cin, string2 ); // now call function to print the string cout << "myString= "; printString( myString ); cout << "string2= "; printString( string2 ); } // end of main()