Computing.Net > Forums > Programming > Input-Output in C++

Input-Output in C++

Reply to Message Icon

Original Message
Name: Avon
Date: April 28, 2003 at 03:27:44 Pacific
Subject: Input-Output in C++
OS: xp
CPU/Ram: 800mhz
Comment:

I want to write a program that repeatedly reads lines of data from a data file lakes.dat (using a loop). It sorts the data according to the condition below into two output data files (ifs). The program must also keep track of the number lakes in each file (two counters). The program should calculate the average area of lakes in each file (two accumulators). These counts and averages are displayed on the screen.


Caspian Russia 152239

Superior Canada 31820

Victoria Uganda 26828

Huron Canada 23010

Michigan, USA 22400

Aral Russia 13000

Tanganyika Tanzania 12700

Baikal Russia 12162

Great Bear Canada 12000

Nyasa Tanzania 1160

The two files should split the data according to the area of the lake. Lakes with area strictly greater than 13000 sq miles are stored in output file “outA.dat”, the rest are stored in file “outB.dat”.

The problem I am having is the last part splitting it into two files. How is the 'if' function used with a getline function for example so the splitting could done for lakes greater than 13000 sq miles?



Report Offensive Message For Removal








Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Input-Output in C++

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge