ok here is my c++ code and I will post my input file but it is not coming out right if someone could please help me figure out how to fix it my last chance to turn it in is tomorrow at midnight and I am close to failing this class please anyhelp would be great... :) :)
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream inputFile;
const int SIZE = 135;
char charHold;
char fileName[SIZE];
ofstream outputFile("encoded.txt");
cout << "Enter name of File: " ; //put plain.txt
cin >> fileName;
//input files
inputFile.open(fileName);
//test the file
if(!inputFile)
{
cout << "Error: File " << fileName << " " << "can not find that name.";
return 0;
}
inputFile.get(charHold);
while (inputFile.good())
{
if (charHold=='/n')
outputFile.put ('/n');
else
outputFile.put(static_cast<int>(charHold) - 5);
inputFile.get(charHold);
}
inputFile.close();
outputFile.close();
cout << "The encoded file is ready" ;
return 0;
}
|
here is my input code
Ymnx%nx%f%xfruqj%nsuzy%knqj%ktw%HTXH%698;
fxxnlsrjsy%(653%^tzw%uwtlwfr%xmtzqi%jshtij%ymnx
knqj%g~%fiinsl%:%yt%ymj%FxHNN%{fqzj%tk%jfhm%hmfwfhyjw%ns%ny3
Ns%~tzw%jshtiji%knqj%ymj%knwxy%hmfwfhyjw%xmtzqi%gj%,^,3%Ymj%
qfxy%hmfwfhyjw%tk%ymj%knwxy%qnsj%xmtzqi%gj%,@,3
Ymj%jshtiji%knqj%xmtzqi%mf{j%=%qnsjx%tk%yj}y%ozxy%qnpj%ymnx%tsj1
gzy%|nqq%gj%zswjfifgqj3%Ymj%qfxy%hmfwfhyjw%tk%ymj%qfxy%qnsj%|nqq%
gj%f%,8,3
and here is what it looks like when encoded
This is a sample input file for COSC 1436assignment #10. Your program should encode thisfile by adding 5 to the AsCII value of each character in it.In your encoded file the first character should be 'Y'. The last character of the first line should be ';'.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 '3'.
and here is what it should look like
This is a sample input file for COSC 1436
assignment #10. Your program should encode this
file by adding 5 to the AsCII value of each character in it.
In your encoded file the first character should be 'Y'. The
last character of the first line should be ';'.
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 '3'.
it all runs on one line instead of on 8 lines Please someone help