Quote Originally Posted by C_ntua View Post
http://www.thinkage.ca/english/gcos/...ib/isspac.html
isspace takes a character as a parameter.
Also, your function has a char** which is an array of strings. So you want to check for every string, what you do has no sense. For one string you would do:
Code:
int cmbString(const void *p, const void *q)
{    
    
    char *pp = (char*)p;
    char *qq = (char*)q;
    int i, j;
    for (int i = 0; isspace(pp[i]); ++i) ;
    for (int j = 0; isspace(qq[i]); ++j) ;
    return strcmp(pp + i, qq + j);
}

edit: You will want to compare a string and not an array of strings in a quick sort algorithm. Each string will be compared and sorted accordingly. The compare function will accept a string (char*) and the qsort algorithm an array of strings (char**)

The above code doesn't seem to work for me. Also as you mentioned, it seems to be checking for all white space in the string, not just leading white space.

In my code, *pp is a char*(a string) in string 1, **pp is a char in the string.

So I want to compare that string with the next string in the array, and sort them in ascending order, ignoring the white space only at the beginning of the string. But obviously I'm having some trouble understanding it.