c - selection sort algorithm for 2d char array -
i trying make selection sort algorithm 2d array in c (as title says), code compiles unfortunately not sort anything.
is there can change make work? or have start on together?
void sortstrings(char strings[5][32]) { int i, j, min; (i = 0; < sizeof(strings); i++){ min = i; (j = 0; j < sizeof(strings-1); j++){ if (strings[i] < strings[min]){ min = 1; } } if (min != i){ swapstrings(strings[i], strings[min]); } } }
also here swapstrings function reference:
void swapstrings(char string1[], char string2[]) { char *temp = string1; string1 = string2; string2 = temp; }
sizeof
returns size taken in memory parameter. in case, size of char isn't size of array. can size of string using strlen function. however, can't size of array strings
you need add parameter function.
Comments
Post a Comment