I need help sorting a list of names that the user enters..
the strcmp routine is tricky..
are there any sites that would prove to be helpful
#include<iostream.h>
#include<string.h>
void SortApplicant( const char*[]);
main()
{
char sentence[80];
for ( int i = 0; i < 10; i++ )
cin.getline(sentence, 40);
return 0;
}
void SortApplicants(char *alpha[])
{
char temp;
int pass, k, row;
for(pass = 0; pass < 10; pass++)
{ for(k = pass; k >=1; k--)
{ if(strcmp(alpha[k], alpha[k-1]) > 0)
{ temp = alpha[k];
alpha[k] = alpha[k-1];
alpha[k-1] = temp;
}
}
}
for(row = 0; row < 5; row ++)
{ printf("%s", alpha[row]);
printf("\n");
}
return;}
practive makes perfect huh
:confused: