943,568 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3800
  • C++ RSS
Jul 23rd, 2004
0

File processing problem

Expand Post »
hai I'm again
I already done my program below. the problem when i run no output appear.
basically I declare 2 file . 1 for input(InTransFile) another one for input and output(InMasterFile).Both in .dat.
I want to compare accno1(masterfile) and accno2(transfile). if they equal
have to overwrite balance1(masterfile) and next record from master will be read

below are the program

#include <iostream>
using std::cout;
using std::cin;
using std::ios;
using std::cerr;
using std::endl;
#include <fstream>
using std::ifstream;
using std::fstream;
#include<iomanip>
using std::setiosflags;
using std::resetiosflags;
using std::setw;
using std::setprecision;

#include <cstdlib>



main()
{
ifstream InTransFile("trans.dat",ios::in);
fstream InMasterFile("master.dat",ios::in|ios::out);


if (!InMasterFile)
{
cerr<<"file could not open\n" ;
exit(1);
}
if (!InTransFile)
{
cerr<<"file could not open\n";
exit(1);
}


int accno1;
int accno2;
double balance1;
double balance2;
int found = 0;

while (!InMasterFile.eof())
{
while (!InTransFile.eof())
{
if (found == 0)
if (accno1 == accno2)
found = 1;

}
cout<<found<<"found";
cout<<accno1<<"master";
cout<<accno2<<"tran";
cout<<accno1<<balance1;


}
return 0;
}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nita is offline Offline
2 posts
since Jul 2004
Jul 23rd, 2004
0

Re: File processing problem

One thing is that you are doing nothing much about the file i/o.Can you explain what you mean by no output.

Check the tutorial fourm for a fstream file i/o tutorial,might help .
Reputation Points: 108
Solved Threads: 7
Posting Whiz in Training
FireNet is offline Offline
256 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Linked List
Next Thread in C++ Forum Timeline: don't understand





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC