I am making a permutation generator in c. Any ideas how I can make it faster?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
char s[] = "abcdefghijklmnopqrstuvwxyz";
int n = 8, c[n], i, l = strlen(s);
char w[n];
for(i = 0; i < n; i++){
c[i] = 0;
w[i] = '\0';
}
w[n] = '\0';
while(c[0] < l){
for(i = 0; i < n; i++){
w[i] = *(s + c[i]);
}
printf("%s\n", w);
c[n - 1] += 1;
for(i = n - 1; i >= 0; i--){
if(c[i] > l - 1 && i != 0){
c[i] = 0;
c[i - 1] += 1;
}
}
}
}