1 of 4

Simply by using recursion instead of loops. This particular version only works on characters between '0' and 'z', but that's just to keep the stack from overflowing too often.

#include <stdio.h>

void walk(char *s, char m){
    if (*s == '\0') return;
    if (*s == m) putchar(m);
    return walk(s+1,m);
}

void sort(char *s, char m){
  walk(s,m);
  if (m<'z') sort(s,m+1);
}

int main(int argc, char**argv){
  if (argc > 1) {
    printf("%s: ",argv[1]);
    sort(argv[1],'0');
    printf("\n");
  }
}

Sample run:

$ ./a.out  thingamabob
thingamabob: aabbghimnot

Too easy, really.