Sorting array of strings in c
Assuming the logic of your sort code is correct.



You can just have your sort function as:

void sort(char **m, int dim);


Your sort function can be like:

void sort(char **m, int dim) {
    int i, j, flag=1;

    for(i=0; i&lt;dim-1 &amp;&amp; flag==1; i++){
        flag=0;
        for(j=0; j&lt;dim-1; j++)
            if(strcmp(m[j],m[j+1])&gt;0){
                swap(&amp;m[j],&amp;m[j+1]);
                flag=1;
            }
    }
}


This improves some readability. There is no need to pass &amp;m - like (sort(&amp;m, N)) - to your sort. Just passing m - like sort(m, N) - is enough for changing/comparing/swapping m[i] and m[j].