http://www.linuxquestions.org/questi...hreadid=108981
the above link has a program for insertion sort for sorting integers. IMPORTANT NOTE : please change the line
esize = malloc(sizeof(int));
to
esize = sizeof(int);
now i want a program to sort strings(not only single letters but also words). i used char data[100]; instead of int data[100]; and in printf and scanf statements i used ("%d", &data[i]);
but the result is coming as:
[prasanth@chanduram prasanth]$ cc issort2.c
[prasanth@chanduram prasanth]$ ./a.out
Enter the number of elements : 5
Enter the list of elements :
a
b
d
e
c
After insertion sort the list of elements :
abcde
bcde
cde
de
e
and for words i get :
[prasanth@chanduram prasanth]$ ./a.out
Enter the number of elements : 5
Enter the list of elements :
elf
bat
dog
ant
cat
After insertion sort the list of elements :
abcdeat
bcdeat
cdeat
deat
eat
please help me