I have a program to write that takes a file and encodes it by putting the ascii value and adding 5 to it and then decodes it by subtracting 5 to the ascii value and showing the character.
I have the file i want encode and decode but im am not sure on how to get every character of the file and convert it.
I was thinking get the contents of the file and put each character into an array and making a loop to run through each character and convert into the ascii but im not sure of the syntax on how to do this.
Any help on this program would be appreciated.
Thank you!
Use the get() member of your fstream object to extract individual characters from the file. Then these chars can be put into a string or array (preferably string) and then encrypted with a simple -=5; They will already be in ascii when you extract them.
Alright here's my code so far to encode the file and it is not showing the ASCII value just some random symbols i was wondering what i am doing wrong or suggestions. ModShop you said to put the chars into a string but how do you do that? If anybody could check out my code and help me id appreciate it.
That is the extended ascii value for the encrypted chars. chars are really just integers that represent characters. You could insert a casted version of the chars to put ints in the file if you really wanted to i suppose.