Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next

 
c++ assignment
Reply
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.
Old
Profile PM WWW Search
osmoses-jones is neither ape nor machine; has so far settled for the in-betweenosmoses-jones is neither ape nor machine; has so far settled for the in-between
 
osmoses-jones
 



 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 02:21 PM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.