i have a program that reads a text file line by line. it performs some calculations and prints the file out to the screen and newly created text file. it works swimmingly except for one thing: it skips the first line of text. i cheated and entered a blank line for the first line of code and it works…except it now prints the last line twice. any suggestions are greatly appreciated.
#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;
int main()
{
//////////////Input File Check////////////////////////
bool flag = false;
fstream bankStatement;
bankStatement.open("bankAccounts.txt");
if(bankStatement.is_open() )
{
cout << "Opening customer account information..." << endl << endl;
flag = true;
}
#include<iostream>
#include<iomanip>
#include<string>
#include<fstream>
using namespace std;
int main()
{
//////////////Input File Check////////////////////////
bool flag = false;
fstream bankStatement;
bankStatement.open("bankAccounts.txt");
if(bankStatement.is_open() )
{
cout << "Opening customer account information..." << endl << endl;
flag = true;
}
.
.
.
string oneLine;
while (bankStatement)
{
string type;
getline(bankStatement, oneLine);
bankStatement >> accountNumber >> accountType >> minBalance >> accountBalance;
.
.
.
}
bankStatement.close();
return 0;
}
string oneLine;
while (bankStatement)
{
string type;
getline(bankStatement, oneLine);
bankStatement >> accountNumber >> accountType >> minBalance >> accountBalance;
.
.
.
}
bankStatement.close();
return 0;
}