#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Program to print all combinations of an input */
char *globalPtr;
void swap (char *a, char *b)
{
char t = *a;
*a = *b;
*b = t;
}
void displayComb (char *s, size_t len)
{
int i;
if (s == NULL) {
return ;
}
if (len == 1) {
printf ("%sn", globalPtr);
return ;
}
displayComb (s+1, len-1);
for (i = 1; i < len; i++) {
swap (s, s+i);
displayComb (s+1, len-1);
swap (s+i, s);
}
return ;
}
Login to rate this answer.