Start New Discussion within our Software Development Community

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;
   using std::setiosflags;
   using std::resetiosflags;
   using std::setw;
   using std::setprecision;

   #include <cstdlib>

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

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

     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;


  return 0;

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 :D.

This article has been dead for over six months. Start a new discussion instead.