OK this is one of my assignment for my computer science class. I have to decrypt a text file using it's position factor. I pretty much figure out how to decode it and output the file. but my issue is that whenever I have it change from ASCII to character and then put it in the text file. It doesn't go to the next line. So pretty much the sentence goes forever on the first line. Pretty much like this.
This is the first line.This is the second line.This is the third line. and etc.
It should be like this
This is the first line.
This is the second line.
This is the third line.
fstream OutputFile ("Decrypt.txt");
getline(FileInput, input, '\n');
int position = 0;
int i = 0;
while (i < input.size())
// Change character to ASCII #
int ASCII = input[i];
// Find position factor
position = position + 1;
int DASCII = position % 5;
// Subtract Position Factor
int Total = ASCII - DASCII;
ch = Total;
// Output to file
i = i + 1;
cout << " File Error! \n";
I figure using the getline(FileInput, input, '\n') would of fix it. But it didnt work. :(
Any hint at the right direction would be greatly appreciated.
Wow... I couldn't believe I didn't think of that. Thanks! it works!
I'm not sure what you mean by my decryption is going to mangle it.
Here's pretty much the text file before it's encrypted.
This is a sample input file for COSC 1436
assignment #10. Your program should encode this
file by adding the position factor to the AsCII value of each
character in it. In your encoded file the first character should
be 'U'. The last character of the first line should be '7'.
The encoded file should have 8 lines of text just like this one,
but will be unreadable. The last character of the last line will
be a '2'.
I ran the program again and it came back just the way it was before I encrypted. :)
I really appreciate the help. I blame me being sick and the med's i'm taking for making me miss something so easy. haha.