Efficiently creating a sequential wordlist from charset
===

I need to find an efficient way to create a list of sequential words created from a given charset in C/C++. Let me give you an example:

If the charset is "abc", the algorithm should output:

      a
      b
      c
     aa
     ab
     ac
     ba
     bb
     bc
     ca
     cb
     cc
    aaa
    aab 
    ... 

I have some ideas, but all are require too much maths and I really need a fast solution. Who's got an idea?