Here is my code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string fname,lname;
double pincrease //pay increase percentage,pay;
ifstream infile;
ofstream outfile;
infile.open("C:\\Users\\Connor\\Desktop");
outfile.open("C:\\Users\\Connor\\Desktop");
while(!infile.eof())
{
infile>>lname>>fname>>pay>>pincrease;
pay = pay*(pay*pincrease);
outfile<<fname<<" "<<lname<<" "<<pay<<"\n";
cin.clear();
}
infile.close();
outfile.close();
}
And here are the contents of my infile
:
Miller Andrew 65789.87 5
Green Sheila 75892.56 6
Sethi Amit 74900.50 6.1
The information is in the form of Last Name:First Name:Pay:Pay Increase Percentage
.
The order swap of the first and last name and the exclusion of the pay percent increase when I write to the outfile
is intentional.
I'm trying to read the contents of the infile
, modify them, and then write it to an outfile
.
However when I execute the code I start what I'm pretty sure is an infinite loop but I'm not sure how to fix it.