Reading Decimal error, and ignoring entire line

my output keeps reading my decimals with a comma instead of a decimal. I have no problems compiling, so I don't know how to get it to stop reading it as a comma where a decimal should be. Also, I'm trying to get it to display the "MNTP" column, and even though I coded for it, it completely ignores the column.

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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "Project2.h"
#include <string>
#include <iostream>

using namespace std;

void weatherSummary ( string inputfile, string outputfile )
{
	ifstream in(inputfile); // read the data from the input file
	ofstream out(outputfile); // send my data to an output text file

	string name;
	int latitude;
	int longitude;
	int elavation;
	int TPCP;
	int MNTM;
	in.ignore(5000, '\n'); //ignore the header
				
	readData( in, name, elavation, latitude, longitude, TPCP, MNTM );
	 
	while( !in.fail() )
	{
		
		//cout << name << elavation << latitude << longitude << TPCP << MNTM;
		
		out << name << "," << elavation << "," << latitude << "," << longitude 
		<< "," << TPCP << "," << MNTM << endl;
		
		readData( in, name, elavation, latitude, longitude, TPCP, MNTM );

	}
	

}


void readData(ifstream& in, string &name, int &elavation, int &latitude, 
	int &longitude, int &TPCP, int &MNTM )
{
	string junk;
	getline( in, junk, ',' );//read from in, store in junk and stop
	//at the comma - and get rid of the comma in the process
	
	getline( in, name, ',' );
	
	in.ignore(500, ',');//ignore the stuff after name of county
	
	in >> elavation;

	in.ignore( 500, ',');//ignore the list of namespace

	in >> latitude;

	in.get();
		
	in >> longitude;

	in.ignore( 500, ',' );//ignore the date line 

	in >> TPCP; //read the TPCP data 

	in.ignore(500, ',');//ignore the missing line

	in.ignore(500, ',');//ignore the consecutive line

	
	in >> MNTM;//get the data for temperature
		in.get(); //get the negative char and do nothing with it


	in.ignore (5000, '\n' );// ignore the rest of the line and end that line


}

int main ()
{
	weatherSummary( "US_partial.txt", "output.txt");
	
	
	return 0;
	
}




here is my header
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
#include <fstream>
#include <iostream>
#include <string>
#include <iostream>
#include <fstream>



using std::string;
using std::ifstream;
using std::ofstream;
using std::cout;
using std::endl;
using std::getline;


double longitude;
double latitude;
double elavation;
int name;
int MNTM;
int TPCP;


void readData(ifstream& in, string &name, int& elavation, int& latitude, int& longitude,
	int &TPCP, int &MNTM );

void weatherSummary ( string inputfile , string outputfile );


and here is the input.txt file


1
2
3
4
5
6
7
8
9
10
11
STATION,STATION_NAME,ELEVATION,LATITUDE,LONGITUDE,DATE,TPCP,Missing,Consecutive Missing,MNTM,Missing,Consecutive Missing
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150101,23,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150201,722,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150301,211,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150401,1198,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150501,671,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150601,647,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150701,768,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150801,112,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20150901,1592,0,0,-9999,0,0
GHCND:US1VACP0007,CULPEPER 6.1 W VA US,177.7,38.4595,-78.1136,20151001,20,0,0,-9999,0,0
Some of the variables declared as integer should be floating point.

    Heading                   Example Data           Field
    _______                   ____________           _____
    STATION                   GHCND:US1VACP0007      ignore
    STATION_NAME              CULPEPER 6.1 W VA US   name
    ELEVATION                 177.7                  elavation
    LATITUDE                  38.4595                latitude
    LONGITUDE                 -78.1136               longitude
    DATE                      20150101               ignore
    TPCP                      23                     TPCP
    Missing                   0                      ignore
    Consecutive Missing       0                      ignore
    MNTM                      -9999                  MNTM
    Missing                   0                      ignore
    Consecutive Missing       0                      ignore

In the header, here double is appropriate
1
2
3
double longitude;
double latitude;
double elavation;

But what about elsewhere in the code?
1
2
3
    int latitude;
    int longitude;
    int elavation;


1
2
void readData(ifstream& in, string &name, int &elavation, int &latitude, 
	int &longitude, int &TPCP, int &MNTM )

Topic archived. No new replies allowed.