/* teststring2.cpp CIS 150 David Klick 7/3/08 This program demonstrates how to sort C-style strings. */ #include #include using std::cin; using std::cout; const int ARRAY_SIZE = 5; void sort(char nm[][20], int len); void cont(); int main() { char names[ARRAY_SIZE][20]; // storage for five names int i; cout << "Entering " << ARRAY_SIZE << " names\n"; // get names from user for (i=0; i 0) { strcpy(temp, nm[i]); strcpy(nm[i], nm[j]); strcpy(nm[j], temp); } } } } /* void cont(); Arguments: none Returns: nothing Clears input buffer and pauses waiting for user to press Enter. */ void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); } /* Sample output: Entering 5 names Enter name #1: Fred Enter name #2: Sue Enter name #3: Thomas Enter name #4: Alexandra Enter name #5: Penelope The names you entered were: Fred Sue Thomas Alexandra Penelope The names in sorted order are: Alexandra Fred Penelope Sue Thomas */