I want to sort arrays with using strcmp . How can do it ?
void sort(char s[100][100], int n){
int i, j, cmp;
char tmp[10];
if (n <= 1)
return; // Already sorted
for (i = 0; i < n; i++)
{
for (j = 0; j < n-1; j++)
{
cmp = strcmp(&s[i][j],&s[i][j+1]);
if (cmp > 0)
{
strcpy(tmp, &s[i][j+1]);
strcpy(&s[i][j+1],&s[i][j]);
strcpy(&s[i][j], tmp);
}
}
}}
I call function for an array like this type :
int main(){
char *result[6][6];
int a=0;
int b=1;
for(a=0; a<5; a++){
for(b=1;b<4;b++){
printf("%s\n", result[a][b]);
sort(result[a][b],6);
}
}
}
how can I fixed this. Now, I have one warning