writing files to a file

Ok, Im trying to simply write one file to another and for some reason Im only getting a blank file. Is it the variables that Im using? or some operation I forgot to add in? It feels like its something really simple. The file is about forest fires.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  #include<iostream>
#include<fstream>

using namespace std;

//Precondition:  
//Postcondition:  
//bool burnedArea(double area);

int main()
{
	float xAxis, yAxis, month, day, ffmc, dmc, dc, isi, temp, rh, wind, rain, area;
	ifstream forestFire;
	ofstream area1;
	forestFire.open("ff.txt");	//ff folder is opened. 
	area1.open("ff1.txt");	//Areas folder is created and opened.
	//area2.open("ff2.txt");	//Areas folder is created and opened.
	if (forestFire.is_open())
	{
		while (forestFire >> xAxis >> yAxis >> month >> day >> ffmc >> dmc >> dc >> isi >> temp >> rh >> wind >> rain >> area)	//The loop will continue to loop as long as there are intergers to pull. 
		{
			//if (burnedArea (area)) 
			//{
				area1 << xAxis << yAxis << month << day << ffmc << dmc << dc << isi << temp << rh << wind << rain << area << endl;
			//}
			//if (!burnedArea(area))
			//{
				//area2 << xAxis << yAxis << month << day << ffmc << dmc << dc << isi << temp << rh << wind << rain << area << endl;	
			//}
		}

	}
	else
	{
		cout << "Input file open failed.\n";	//If the file did not open then it will exit 1
		exit(1);
	}
	forestFire.close();
	area1.close();
	//area2.close();
	return 0;
}

//bool burnedArea(double area)
//{
	//if (area>0)
	//{
		//return false;
	//}
	//else return true;
//} 



ff.text:
1 2 3 4 5 6 7 8 9 10 11 12 13 
7 5 mar fri 86.2 26.2 94.3 5.1 8.2 51 6.7 0 0 
7 4 oct tue 90.6 35.4 669.1 6.7 18 33 0.9 0 0 
7 4 oct sat 90.6 43.7 686.9 6.7 14.6 33 1.3 0 0  ...   

Attribute Information: 
1. X ‐ x‐axis spatial coordinate within the Montesinho park map: 1 to 9  
2. Y ‐ y‐axis spatial coordinate within the Montesinho park map: 2 to 9   3. month ‐ month of the year: 'jan' to 'dec'   4. day ‐ day of the week: 'mon' to 'sun'   5. FFMC ‐ FFMC index from the FWI system: 18.7 to 96.20   6. DMC ‐ DMC index from the FWI system: 1.1 to 291.3   7. DC ‐ DC index from the FWI system: 7.9 to 860.6   8. ISI ‐ ISI index from the FWI system: 0.0 to 56.10   9. temp ‐ temperature in Celsius degrees: 2.2 to 33.30   10. RH ‐ relative humidity in %: 15.0 to 100   11. wind ‐ wind speed in km/h: 0.40 to 9.40   12. rain ‐ outside rain in mm/m2 : 0.0 to 6.4   13. area ‐ the burned area of the forest (in ha): 0.00 to 1090.84  
Last edited on
The first thing I see is that you have string data that you're trying to insert into a numeric variable. This will cause your stream to fail. Once the stream fails no other processing of that stream will be possible until the errors are cleared.

See I knew that it was something small that I missed. lol Thanks!!
Topic archived. No new replies allowed.