Here's your code, working, minus the typedefs.
Code:
#include <stdio.h>
#include <string.h>
typedef int bool;
void str_swap(char **str1, char **str2);
void bubble_sort(char *array[], int length)
{
int i, j, s;
bool flag = 1;
int arrayLength = length;
for (i = 0; (i < arrayLength) && flag; i++)
{
flag = 0;
for (j = 0; j < (arrayLength - 1); j++)
{
s = strcmp(array[j + 1], array[j]);
if (s < 0) //string 2 is greater
{
flag = 1;
str_swap(&array[j + 1], &array[j]);
}
}
}
}
int main(void)
{
char *strs[] = { "Alfred", "Albert", "Linux", "Penguin", "Lorraine", "Lucas" };
int j, len = 6;
for (j = 0; j < len; j++) printf("%s ", strs[j]);
printf("\n");
bubble_sort(strs, len);
for (j = 0; j < len; j++) printf("%s ", strs[j]);
printf("\n");
return(0);
}
void str_swap(char **str1, char **str2)
{
char *tmp;
tmp = *str1;
*str1 = *str2;
*str2 = tmp;
}
To add your typedefs back in, simply go through and replace the relevant bits. But you two typedefs are definately bad style imo.