C permutation generator I am making a permutation generator in c. Any ideas how I can make it faster?

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

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 &lt; n; i++){
        c[i] = 0;
        w[i] = '\0';
    }
    w[n] = '\0';
    while(c[0] &lt; l){
        for(i = 0; i &lt; n; i++){
            w[i] = *(s + c[i]);
        }
        printf("%s\n", w);
        c[n - 1] += 1;
        for(i = n - 1; i &gt;= 0; i--){
            if(c[i] &gt; l - 1 &amp;&amp; i != 0){
                c[i] = 0;
                c[i - 1] += 1;
            }
        }
    }
}
Buffer overrun

Your array w should be one larger than it currently is to hold a null terminating character.  Otherwise when you write to w[n] you are writing past the end of the array.

Excess copying

Currently, every time you generate a new permutation, you rewrite all of the w array.  You actually only have to rewrite the parts that changed since the last permutation.  To do this, you should write to w[i] only when c[i] changes.  So for example:

while(c[0] &lt; l){
    c[n - 1] += 1;
    w[n - 1] = s[c[n - 1]];
    for(i = n - 1; i &gt;= 0; i--){
        if(c[i] &gt; l - 1 &amp;&amp; i != 0){
            c[i] = 0;
            w[i] = s[0];
            c[i - 1] += 1;
            w[i - 1] = s[c[i - 1]];
        }
    }
}


Alternate implementation

If you are looking to find a faster way to generate permutations, I suggest you look at this codereview question and in particular my answer to it.