The code is working with just one problem. The first letter in each encryption (and possibly decryption) is not changing. I don't believe it's my mapping function but I do think it's within the "encryptdecrypt" function.
Getting the input/output file portion of the code is fine. I've messed up somewhere within my functions besides main (I think).
Here's the code. Sorry there aren't any comments yet. The code takes an input file and either encrypts or decrypts it line by line (a=0...z=25).
Do you have an example input file and an expected input file. I've been trying to follow it, but I have no clue what kind of results are expected, what kind of input, etc. I'll take a closer look at it with some files though.
The first letter in each encryption (and possibly decryption) is not changing.
If the first letter of your key is an 'a', the encrypted version of the letter would be whatever the letter was. In fact anything encrypted with the key "a" (or "aa", etc) will be the same as it's decrypted text.