hey guys !!!
i have to sort the students according to their first and last names
here is the code i have written so far ,, it inputs the first names and last names and then it stops working . please help me with this ,, thank u
#include <iostream>
#include <string>
using namespace std;
struct Student
{
string FirstName ;
string LastName ;
};
void inputFromUser (Student *S );
void SortArray (Student *S);
int main ()
{
Student s ;
inputFromUser(&s);
SortArray(&s);
system("pause");
return 0 ;
}
void inputFromUser (Student *S)
{
for ( int i = 0 ; i<10 ; i++)
{
Student *S = new Student [10] ;
cout << " enter the first name " << endl;
cin >> S[i].FirstName ;
cout << " enter last name " << endl;
cin >> S[i].LastName ;
}
}
void SortArray (Student *S)
{
string temp[10] ;
string temp1[10] ;
for (int i = 0 ; i<10 ; i++ )
{
if (S[i].FirstName >S[i+1].FirstName && S[i].LastName > S[i+1].LastName)
{
temp[i] = S[i].FirstName ;
temp1[i] = S[i].LastName ;
cout << temp[i] << " " << temp1[i] << endl;
}
}
}