this program should output the names in ascending order which entered by the user. i know there is wrong under if(strcmp...) part..because i do not how to order it...
can someone show me how to continue..
thank you..
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char name[4][50];
//char temp[50];
for (int i=0; i <=3; i++)
{
cout << "Enter student name [" << i+1 << "]: ";
cin.getline(name, 50 );
}
if ( strcmp(name, name[i+1]) > 0)
{
for (int i=0; i<4 ; i++){
//strcpy(temp,name); //not sure!!
strcpy(name[i+1],name);
//strcpy(temp,name[i+1]);
//strcpy(name[i+1],name);
}
for (int a=0; a < 4 ; a++)
cout << name[a][50] << endl;
}
else
for (int b=0; b<=3 ; b++)
cout << name<< endl;
return 0;
}