Hi, guys,
I've been working on sorting an array of strings... It is a work in progress, I did not take into consideration blank spaces, uppercase or lowercase characters as of yet. I need to get thi sfunction into a working condition to work on details.
When I compile it (no warnings or erros at all, gcc) and run the program, it finishes. So I take a look in my sorted array file and I see just blank lines.
Can anybody tell me what happened?
Code:
void InsertionSort(char *arr[])
{
char *helper = "......................";
int i, j;
for(i = 1; i < (int)strlen(arr[i])-1; i++) {
strcpy(helper, arr[i]);
j = i;
while(j >= 1 && (strcmp(helper, arr[j-1])<0)) {
strcpy(arr[j], arr[j-1]);
j -= 1;
}
strcpy(arr[j], helper);
}
}