char array problem

I'm having some problems with modifying a char array.
At first, I merely define it, i.e.char modAlpha[65];

And then after that comes a user input loop, that modifies this char array.
So what happens is that the code asks you to type whatever you want, and then from that input it produces a sort of shuffled alphabet (hence the name modAlpha -- mod as in modified). Ideally, this process should be repeatable, which is where the problem kicks in.
Now, what confuses me is that the first time, it works perfectly, while the second or third or whatever time around, modAlpha becomes a zero-length array.

In general terms, this is the code:

- Define array: char modAlpha[65];

- Loop
- Take input (works every time)
- Use that input to modify modAlpha
[repeat]

The first time this loop runs, it works, meaning that the letters are shuffled around correctly, while any run after the first reduces modAlpha to nothing.

And the functions here do the following:
- inputKey just takes in a user input string and checks its length. Nothing special, and works. All it does is checking length and creating a char array out of user input.
- key is where something fishy is going on. It looks like this:[Just a quick explanation of what this function should do: it takes a normal sort of extended alphabet -- lowercase letters, uppercase letters, numbers and some symbols -- and compares this with a short user input char array. The deal is that it inserts every unique element of this extended alphabet into a new array (modAlpha), but the order depends on the input. It starts with the first character of the input, and then runs through it, and finally the rest of the available characters until modAlpha contains all the same elements as the extended alphabet, but in a different order. Sorry if that's just confusing. I guess an important note here is that it does work the first time. It's only the second and so forth that doesn't work.]

So to just repeat the problem:
- First time the loop runs, it works, and the length of modAlpha is 65 (Good)
- Every run after this, the length reduces to 0 or 1, or something way way less than 65, which is bad.