|
|
|
 |
Posted 2007-05-20, 07:37 PM
|
 |
 |
 |
i got the first part done but i have second part that confuse me i have to write a write function that write in outputdata.dat all total of number in inputdata.dat.
here the code i got it work to display what inside inputdata.dat.
Code:
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#define BUF_SIZE 21
#define IN_FILE "InputData.dat"
extern void main( void )
{
ifstream ifInputFile;
ofstream stream;
char sBuffer[BUF_SIZE];
bool bDataExists(true);
ifInputFile.open("InputData.dat");
if( ifInputFile.is_open() != 1 )
{
cout << "File " << IN_FILE << " could not be opened!" << endl;
cout << "Exiting program, good bye." << endl;
}
else
{
while( bDataExists == true )
{
ifInputFile.getline( sBuffer, 40 );
if( ifInputFile.eof() == 1 )
{
bDataExists = false;
}
else
{
cout << sBuffer << endl;
}
}
ifInputFile.close();
}
} |
here what it display
23
36
54
75
88
64
i have to write a code that add all this number and use write function to put it in output.dat file. It confuses me i get alot of errors. Thanks for helping me.
Last edited by Lenny; 2007-05-22 at 04:51 AM.
|
 |
 |
 |
|
|
|
|
|
|
|