im the newbie among the newbie .....need a nice and patient guy who willing to guide me of my assignment.....cause the deadline is tis weekend......i dun know or can say hard to post the problem out...cause too many.............need urgent reply.........can msn ??? pls pls pls pls...........i got plenty of question to ask......really need a patient guy ........

haiz....all sleep?
hope tat hav ppl can ans my question now.....

#include <fstream>
#include <iostream>
#include <cstdlib>


int main( )
{
using namespace std;
ifstream in_stream;
ofstream out_stream;


in_stream.open("infile.dat");
if (in_stream.fail( ))
{
cout << "Input file opening failed.\n";
exit(1);
}


out_stream.open("outfile.dat");
if (out_stream.fail( ))
{
cout << "Output file opening failed.\n";
exit(1);
}


int first, second, third;
in_stream >> first >> second >> third;
out_stream << "The sum of the first 3\n"
<< "numbers in infile.dat\n"
<< "is " << (first + second + third)
<< endl;


in_stream.close( );
out_stream.close( );


return 0;
}

wat if i wan to read all integer number ???wat should i do?

Edited 3 Years Ago by happygeek: fixed formatting

i am afraid thats all i can do...try reading line by line convert to each string to int and add them ...

This question has already been answered. Start a new discussion instead.