You need to test your program thoroughly each step of the way.
1 2 3
|
ifstream fin;
string fileName;
getline(fin,fileName)
|
What file is your program currently getting input from?
// 111111111111
Pretty sure this is over the max for an integer variable, which will cause problems.
|
fin>>firstName>>lastName>>SSN>>birthYear>>empStart>>mSalary>>jobTitle;
|
I feel like this should be in your
while
statement. Also, this line of code doesn't take into account that
fin >> somevariable
is going to eat up the newline character.
std::ofstream file;
If you're
using namespace std;
you don't need to use the scope resolution operator, you can just type
ofstream fout;
or whatever. I also don't understand why you've created two objects of ofstream (
fout /* and */ file
)
Your
return 0;
should be the last thing, right before the last brace (
}
) of your
int main ()
function.
Very last line, there's a random semi-colon as well.
Okay, so start off with this:
1 2 3 4 5 6 7 8
|
// okay, if I'm not sure how to properly use file input output
// I'm going to try to get a line of code from the file first, before I do anything else with it
// after I have all of the values stored into different variables
// I'm going to display them to the screen to ensure it's working properly, then move on to the next step
// alright, got one line and it's displaying properly to the screen, now I'm going to do the same thing except I'm going to get several lines of input and display it
// so on and so forth as you slowly, SLOWLY build up your program's functionality
|
Whenever I don't know how to do something, the last thing I want to do is confuse myself with a bunch of code. I start extremely simple in order to ensure I understand what's going on, and if something does go wrong (and trust me, it has, many times, it happens to everyone), it's drastically easier to fix when your program has a total of 10 lines of code in it (and thats including the includes, namespaces, and whatnot).