Please keep the laughing until the end of this request.
The new assignment that I have to work on, is a string sorter. I am to ask the user to enter how many names does he/she need to sort, should be a number between 2 and 25. Then sort these names alphabetically in the order the user chooses.
The code is written for all of the above.
My question is:
NOT USING ARRAYS, because it is not yet covered in class how can I use an elegant For-Next loop to enter all these names?
So for example:
How many names do you want to sort: user enters 5, gets stored in variable iHowManyNames
Then you have:
For (iCounter = 1; iCounter <= iHowManyNames; iCounter++)
[tab]cout << "Enter name " << iCounter << " of " << iHowManyNames << " :";
[tab]cin.getline (cName, 20);
Now obviously this will not work, because all the names will be entered into a single variable, cName and thus I will capture only the last one entered. But my question is about an elegant alternative to:
cin.getline (cName1, 20);
cin.getline (cName2, 20);
cin.getline (cName3, 20);
cin.getline (cName4, 20);
cin.getline (cName5, 20);
Thanks for any idea