formatting

I read from a file and am printing to another file this what the printerfile looks like, what is wrong with the source code for it to not format correctly

-1217278520 JOHNROGERS1.14449e+243
-1217278520 1MIKE1.14449e+243
-1217278520 JOHN4441.14449e+243
-1217278520 ROD31.14449e+243
-1217278520 555JORDAN1.14449e+243
-1217278520 4CHARLES1.14449e+243
-1217278520BARKLEY9001.14449e+243
-1217278520MAJIC61.14449e+243
-1217278520 100MIRRA1.14449e+243
-1217278520 7GAURANG1.14449e+243
-1217278520PATEL1e+071.14449e+243
-1217278520MILES91.14449e+243
-1217278520100000BUCKLEY1.14449e+243
-1217278520 10800001.14449e+243

this is what my printerfile is looking like , i am not sure if my formatting is wrong , below is what the source code looks like

#include<iostream>
#include<fstream>
#include<cstring>
#include<iomanip>
using namespace std;

//function prototypes
void Initialize(fstream&bankfile,fstream&printerfile);
void Readandprint(fstream&bankfile,fstream&printerfile);
void Finalize(fstream&bankfile,fstream&printerfile);

main()
{
fstream bankfile;
fstream printerfile;
Initialize(bankfile,printerfile);
Readandprint(bankfile,printerfile);
Finalize(bankfile,printerfile);
}//main

void Initialize(fstream&bankfile,fstream&printerfile)
{
char Filename[51];
char Printfile[50];
cout << "Enter name of the file to be open:";
cin >> Filename;
bankfile.open(Filename, ios::in);
cout << "Enter name of the file to be sent to:";
cin >> Filename;
printerfile.open(Filename,ios::out);
if(bankfile.fail())
{
cout << "Error on opening the file"
<< endl;
}//if
if(printerfile.fail())
{
cout<< " Error on opening the file"
<<endl;
}//if
}//Initialize

void Readandprint(fstream&bfile,fstream&pfile)
{
int acctid;
char fname[11];
char lname[11];
double balance;

bfile >> fname;

while(!bfile.eof())
{
bfile >> lname;
bile >> acctid;
bfile >> balance;
pfile <<fname << setw(5) << lname
<<setw(5) << acctid<< setw(5) balance
<<endl;
bfile >> fname ;
}//while
}//Inputandwrite

void Finalize(fstream&bfile,fstream&pfile)
{
bfile.close();
cout<< " Full closed- terminating"
<<endl;
pfile.close();
cout<< " Closing everything"
<<endl;
}//finalize
Topic archived. No new replies allowed.