[try Beta version]
Not logged in

 
Pulling data from a text

Jan 30, 2018 at 12:36pm
I'm new to C++ and I'm having issues pulling data from a .txt file. What I have is a .txt with multiple entries per line; it looks like.

firstName midName lastName department origSalary percentIncrease

And I'm supposed to output with a header the data to:

Last First Mid. Initial Depart. Original Salary Amount of Increase New Salary

lastName, firstName midInitial department origSalary increaseAmount newSalary

I'm so lost to how to do this that any help would be greatly appreciated.

Last edited on Jan 30, 2018 at 12:36pm
Jan 30, 2018 at 2:00pm
Your code will look something like this:


ifstream infile(filename);

while(infile >> fname >> lname ... etc )//text file reading works just like cin
{
do something with the variables you read;
}




Topic archived. No new replies allowed.