First off, I am using visual c++ so it needs to work on that program. I am creat
ID: 3622391 • Letter: F
Question
First off, I am using visual c++ so it needs to work on that program. I am creating a file that uses ifstream for input, ofstream for output. Then it must create a new file that encodes the information gathered by subtract 5 to the ASCII value of each character. I am having a horrible time with this and I know that my code isn't even close. It is because I get constant errors and I don't know where to go with it. Someone help me plz. Also, how do I attach these in and out files? Where to I put them? No matter what, I keep getting an error saying unable to locate and open the files. It says to Put a coded file (such as plain.code) in the same directory as your C++ executable program. The program should:
1.Read the text file one line at a time.
2.Change each character of the string by subtracting 5 from it.
3.Write the encoded string to a second file, such as plain2.txt
#include
#include
#include
using namespace std;
int main () {
const int SIZE = 24;
char fileName[SIZE];
char ch;
ifstream infile("plain.txt");
ofstream outFile("plain2.txt");
string line;
if (!inFile)
{
cout << "Cannot Open " << fileName << endl;
return 0;
}
myfile.close();
system("PAUSE");
return 0;
}
Explanation / Answer
Dear, Here is the code #include #include using namespace std; int main () { const int SIZE = 24; char fileName[SIZE]; char ch; ifstream infile("plain.txt"); ofstream outFile("plain2.txt"); string line; if (!inFile) { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.