| | |
help me...wher i did wrong?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 21
Reputation:
Solved Threads: 0
#include <iostream>
#include <fstream>
using namespace std;
int main( )
{
ifstream fin;
ofstream fout;
fin.open("income.dat");
if (fin.fail( ))
{
cout << "Input file opening failed.\n";
exit(1);
}
fout.open("total.dat");
if (fout.fail( ))
{
cout << "Output file opening failed.\n";
exit(1);
}
double next, sum = 0;
int count = 0;
while (fin >> next )
{
sum = sum + next;
count ++;
}
fin.close( );
fout.close( );
cout << "End of program.\n";
return 0;
}
i wan to make a program tat can read all the number in the file.....but it cant .... y?
#include <fstream>
using namespace std;
int main( )
{
ifstream fin;
ofstream fout;
fin.open("income.dat");
if (fin.fail( ))
{
cout << "Input file opening failed.\n";
exit(1);
}
fout.open("total.dat");
if (fout.fail( ))
{
cout << "Output file opening failed.\n";
exit(1);
}
double next, sum = 0;
int count = 0;
while (fin >> next )
{
sum = sum + next;
count ++;
}
fin.close( );
fout.close( );
cout << "End of program.\n";
return 0;
}
i wan to make a program tat can read all the number in the file.....but it cant .... y?
Last edited by ricnyx; Nov 26th, 2007 at 5:25 am.
![]() |
Similar Threads
- My CD-RW plays but won't burn. What could be wrong?? Help Please? (Storage)
- Retrieve email I sent to the wrong person (Web Browsers)
- Ram voltage wrong?? (Motherboards, CPUs and RAM)
- Am I going about this the wrong way (IT Professionals' Lounge)
- wats wrong with imesh??? (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: OpenGl, Visual c++ and textures
- Next Thread: Legal Bools
Views: 841 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





