Hello,

I am having trouble with my sorting function. I am trying to sort 5 strings. After I input all 5 strings, the program hangs. When I comment out the while loop, it prints the five strings(though not sorted), so the problem is with the while loop. I can't seem to find what I am doing wrong. Any suggestions?

Code:void string_sort(char * strings[], int num) { char *temp; int i, j; int sorted = 0; while(sorted!=1) { sorted = 1; for(i=0; i<num-1; i++) for(j=1; j<num; j++) { if(strcmp(strings[i], strings[j]) > 0) { temp = strings[i]; strings[i] = strings[j]; strings[j] = temp; sorted = 0; } } } }