anyways, text.txt is what you input for the program to encode, encoded.txt is the text encoded, and debug.txt just shows if the text is read correctly.
now it works fine, but after it is done with the text in text.txt it just adds a lot of random symbols and i cant understand why. any ideas?
When the loop reaches the '\0' character, it doesn't stop. Only the first break actually does anything, and that just brings you out of the switch statement. What you can do instead is write something like this:
case'\0' : x = 1001; break;
This means that the for loop will stop executing as well
also i should point out that sizeof(a) will always return 1000, regardless of how long the string inside it is. Actually i think you could use strlen(a) to give you the correct length of the string.