i am using microsoft visual c++ and cant get this to run. i have the file in the right spot.....any suggestions, or do you need any more info from me.....it always tells me that there is an error opening the file....
using namespace std;
cout<< "Enter file name to open:";
cin >> filename;
cout << "Error opening" + filename + "\n";
//We're outa here.
string firstname,lastname,ssn; //ssn has to be a string because the input
int age; // text has minues (-) in it. So you can't use an int.
int total=0; //We'll use this to add up the ages as we get them.
//Loop until end of file
fin >> firstname;
//If the firstname is blank, we don't have a line. It's probably just
// the carriage return at the very end of the file.
if (firstname != "")
fin >> lastname;
fin >> ssn;
fin >> age;
cout << firstname << " " << lastname << " " << ssn << " " << age << "\n";
//Add the age to the total. total = total + age is another way to write it.
total += age;
cout << "Total= " << total;