C permutation generator
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.