okay, i usually create beg programs and they often compile. for some reason, this one is not compiling at all. i cant seem to figure out whats wrong.
my objective is to prompt user to open a file named "data.txt"
have HELLO WORLD printed in a scrambled version to a file named "secret.txt"
and also have it printed to the console screen.
but first and foremost, my bigger problem is not having the program compile properly. any have any suggestions?
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
ifstream fin;
fin.open("data.txt");
if (!fin.good()) throw "I/O error";
string fileName;
cout << "What file do you want to use for input? ";
getline(cin, fileName);
fin.open(fileName.c_str());
ofstream fout;
fout.open("secret.txt", ios::app);
if (!fin.good()) throw "I/O error";
fout << " " << endl;
fout.close();
// encode string s by adding 1 to the ASCII code of each character
string s = "Hello, World"; // an example
for (int i = 0; i < s.length(); i++) // for each char in the string...
s[i]++; // bump the ASCII code by 1
while (true)
{
if (!fin.good()) break;
string lineFromFile;
getline(fin, lineFromFile);
cout << lineFromFile << endl;
} // while
fin.close();
cin.ignore();
cin.get();
return 0;
}