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!!

for (int a=0; a < 4 ; a++)
cout << name[a][50] << endl;



for (int b=0; b<=3 ; b++)
cout << name<< endl;

return 0;

Have you done swapping of integers? The same principle applies. Make a temporary copy of a, write b to a, write the temporary copy to b. With integers, you could use simple assignment; with C-style strings, you use strcpy.