Hello, I am having a little trouble writing this program that lets the user enter an amount of names equal to the number of students in the class. I got up to the part where I enter the names, but sorting the names is proving to be quite difficult at my level at the moment. Can anyone please tell what I should add?
#include <iostream>
#include <cstring>
usingnamespace std;
int main()
{
constint SIZE = 30;
int num_student, //number of students
count = 0;
char students[SIZE]; //name of student(s)
cout << " How many students are there in this class? ";
cin >> num_student;
cout << "\n What are the students names? First names only." << endl;
for(count = 1; count <= num_student; count++)
{
cin.getline(students, SIZE);
if(strcmp(students) < 0)
{
cout << students << endl;
}
}
/*do
{
count++;
cin.getline(students, SIZE);
}while(count <= num_student);
*/
return 0;
}
Edit: I don't know if I should use a do loop or a for loop...