How would I convert this C-program which alphbetiizes a string using qsort into a C-program which does the same thing using BubbleSort instead?:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 7
int comp(const void *s1, const void *s2);
int main( void )
{
char *data[MAX], buf[80], *ptr, *key, **key1;
int count;
printf("Enter %d words, pressing Enter after each.\n",MAX);
for (count = 0; count < MAX; count++)
{
printf("Word %d: ", count+1);
gets(buf);
data[count] = malloc(strlen(buf)+1);
strcpy(data[count], buf);
}
qsort(data, MAX, sizeof(data[0]), comp);
for (count = 0; count < MAX; count++)
printf("\n%d: %s", count+1, data[count]);
return 0;
}
int comp(const void *s1, const void *s2)
{
return (strcmp(*(char **)s1, *(char **)s2));
}