| | |
File processing problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2004
Posts: 2
Reputation:
Solved Threads: 0
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;
}
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
- Help with file processing problem (C)
- file processing, Random-access Files (C++)
- File Processing C++ (C++)
- Help!..."File Processing" *questions inside* (C++)
- File Processing (C)
Other Threads in the C++ Forum
- Previous Thread: Linked List
- Next Thread: don't understand
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






.