Encoding a text document

Hello everyone,

My name is Chris and I'm having a little trouble on my encoding assignment. The help you guys provided made me able to finish my last project and has been truly invaluable, so I've come back :)

Anyways I've reached an impasse in my program. I have successfully opened the text document that I'm suppose to encode (a quote of my choice) and I've created a new file where the encoded quote should be contained. As far as encoding it, I'm at a loss.

My friend said I need to convert the letters to numbers and then add 2 to the numbers (encoding the message by moving all letters two places to the right ex. a becomes c and b becomes d) and that ASCII would be my best bet. I've read the ASCII wiki but I'm having trouble understanding it. Any tips, pointers, or examples would be appreciated :D

Anyways here is what I've got so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
string input, filename1, filename2;
filename1="quote.txt";
ifstream text;
text.open(filename1.c_str());
getline(text, input);
cout<<"The quote you are encoding is..."<<endl<<input<<endl;
text.close();

// This area is where I need to write my function for moving the places of the letters
    
getline(text, input);
filename2="quote2.txt";
ofstream text1;
text1.open(filename2.c_str());
text1<<input;
text.close();
cout<<endl<<"Your code is stored in a new text document called quote2"<<endl<<endl;
    
    system("PAUSE");
    return 0;
}


Right now I'm thinking what if I write out the alphabet in numbers, say a=1 b=2 and such, and then adding two to the entire text, so that's what I'm at right now. Guidance is appreciated!
It might be Caesar cipher:

http://en.wikipedia.org/wiki/Caesar_cipher
Topic archived. No new replies allowed.