Q:

Find the maximum in a string

Given an array of strings, I have to find the maximum (in lexicographical sense) in each string, and make a string out of this. 
I've come out with this function:
void get_max_string(sa str_arr, int dim, string max_car) {

    int i, j;

    for(i=0; i<dim; i++) {

        for(j = 0 ; j+1 < strlen(str_arr[i]) ; j++) {

            if (str_arr[i][j] > str_arr[i][j+1])

                max_car[i] = str_arr[i][j];
        }
    }
    return;
}

"sa" is a string array, "string" is obviously a characters array.
The problem is that it seems to ignore the first character.
What's the error?

A:

Here is a solution and I try to make use of your code. The problem of your code is you don't assign max_arr[i] to an initial value .
void get_max_string(sa str_arr, int dim, string max_car) {

    int i, j;

    for(i=0; i<dim; i++) {
        max_car[i] = str_arr[i][0]; //init max_car[i] with the first letter

        for(j = 0 ; j + 1< strlen(str_arr[i]) ; j++) { 

            if (max_car[i] < str_arr[i][j+1])

                max_car[i] = str_arr[i][j+1]; // find a larger value
        }
    }
    return;
}

