Sorry guys, am back again with another noob question and hoping someone is nice enough to help point me in the right direction.I've only began to learn this in the past couple of weeks so there is still alot am confused about. Really wish i didnt have to come here and ask dumb questions but i need to learn this by all means and nowhere else to go.
I am trying to write a program that will allow input of names in any order and sort the names based on the first character.
My code is below - it allows the names but does not sort. I know i should "store the names" somehow so i can sort and retrieve them but i dont know how.
I havent learnt sorting or array yet, just on chapter 5 of my book so i dont think i should be using those - though have tried to read-up on it but i still cant apply the concept to this simple problem.
Would appreciate any help.
Thanks.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int num_of_students;
int x=0;
string name;
cout << "how many student" << endl;
cin >> num_of_students;
while ((num_of_students < 2)||(num_of_students > 25))
{
cout<<"Invalid entry"<<endl;
cout<<"Please enter number greater than 2 and less than 25"<<endl;
cin>>num_of_students;
}
for (x=1; x <= num_of_students; x++)
{
cout << "enter name" << endl;
cin >> name;
}
cout << "the formation_line is: " << name << endl;
system("PAUSE");
return 0;
}