Gamingphreek
Lifer
I am trying to read a file in C++ and take each of the Characters and increase them by 2 characters (For instance A would be C).
I can get the file to read, but seeing as I haven't done this in 4 years, I can't seem to get the code to work that reads the characters and increases them and then outputs them to their very own file.
Thank You so much,
-Kevin
Edit: I have no idea what is wrong with the code window. It is going haywire-- if anyone can read what I have typed, that would be great though. I can't put it in a window, but hopefully this will help
#include <fstream>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
string filename;
char Characters;
int X;
ifstream Original_Doc;
cout << "Please enter the file name\n";
cin >> filename;
Original_Doc.open(filename.c_str());
if (!Original_Doc)
{
cout << "Unable to open file Original_Doc";
exit (1);
}
else
{
Original_Doc >> Characters;
for (X=1; X<= Characters; X++)
{
Original_Doc >> X;
cout << X;
}
}
return 0;
}
I can get the file to read, but seeing as I haven't done this in 4 years, I can't seem to get the code to work that reads the characters and increases them and then outputs them to their very own file.
Thank You so much,
-Kevin
Edit: I have no idea what is wrong with the code window. It is going haywire-- if anyone can read what I have typed, that would be great though. I can't put it in a window, but hopefully this will help
#include <fstream>
#include <string>
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
string filename;
char Characters;
int X;
ifstream Original_Doc;
cout << "Please enter the file name\n";
cin >> filename;
Original_Doc.open(filename.c_str());
if (!Original_Doc)
{
cout << "Unable to open file Original_Doc";
exit (1);
}
else
{
Original_Doc >> Characters;
for (X=1; X<= Characters; X++)
{
Original_Doc >> X;
cout << X;
}
}
return 0;
}