Can anyone help me figure out what I'm doing wrong. I'm new to programming and for my class we had to modify the program so that it reads its input from a text file and the output of the program should go to the screen -- only the input is to be file-based.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
// open aboutYou.txt for input
ifstream fin;
fin.open("aboutYou.txt", ios::app);
if (!fin.good()) throw "I/O error";
// read an int value from one line of an input file
int age;
fin >> age;
fin.ignore(1000, 10);
// read a double value from one line of an input file
double gpa;
fin >> gpa;
fin.ignore(1000, 10);
// read a string value from one line of an input file
string name;
getline(cin, name);
// read a char value from one line of an input file
char gender;
fin >> gender;
fin.ignore(1000, 10);
// print output
ofstream fout;
fout.open("aboutYou.txt", ios::app);
fout << endl;
fout << age << endl;
fout << gpa << endl;
fout << name << endl;
fout << gender << endl;
fin.close();
return 0;
}