Why are you set on insertion sort? Is it a requirement of your assignment? The function qsort is available in the standard library. If you want others you get to write them.
When using a function such as qsort, you pass in a pointer to a comparison function. In such a function would be a call to strcmp if the array of structures will be sorted on strings, and the result of this call would be the return value of the comparison function. From an old, unrelated bit of code:
Code:
struct person
{
char name[32];
int num;
};
int cmp_name(const void *a, const void *b)
{
const struct person *x = a, *y = b;
return strcmp(x->name, y->name);
}
/* ... */
qsort(in, count, sizeof *in, cmp_name);
/* ... */
If you are doing it yourself, I would guess that you would likely have the comparison function in your sort preceding the swap.
Why not post the whole code of your attempt thus far?