关于#字符串排序#的问题,如何解决?

编辑一字符串,将输入的所有“ * ”号放到最后,帮我瞅瞅有哪些问题吧。基础c语言
#include <stdio.h>
int main()
{
int n=0,i,t;
char a[100];
printf("输入一串字符:");
gets(a);
printf("%s\n", a);
for(i=0;i<=10;i++)
if (a[i] = '*')
{
a[i + 1] = a[i];
n++;
}
return 0;
}

if (a[i] == '*')

#include <stdio.h>
#include <string.h>

// swap two characters
void swap(char *a, char *b)
{
    char t = *a;
    *a = *b;
    *b = t;
}

// return the cateogyr of the character, 1 for *, 0 for other characters
int category(char a)
{
    return a != '*' ? 0 : 1;
}

// compare two characters according to their categories
int compare(char a, char b)
{
    return category(a) - category(b);
}

// bubble sort the string according to their categories
void sort(char s[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < n - 1 - i; j++)
        {
            if (compare(s[j], s[j + 1]) > 0)
                swap(&s[j], &s[j + 1]);
        }
    }
}

int main(void)
{
    const int N = 255;
    char buffer[N];
    printf("输入一串字符串:");
    fgets(buffer, N, stdin);
    buffer[strlen(buffer) - 1] = '\0'; // remove the trailing newline
    sort(buffer, strlen(buffer));
    printf("%s\n", buffer);
    return 0;
}
$ gcc -Wall main.c
$ ./a.out
输入一串字符串:*a12 *b34**cde*
a12 b34cde*****