where should i use ignore.

Im a little confused about where to put the fin.ignore for everything to be straight. below is my code and below that is what my cout looks like.


//Landon Hillyard
//A00362499
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;


//This program will report the total rainfall for the stations reported.

int main()
{
string name;
double elevation, jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec,
raintotal;
const int WIDTH1=25,STATION=78;
int i;

ifstream fin;
fin.open ("monthlyPrecipitation.txt");

if(fin.fail())//if file doesnt open.
{
cout<<"Error could not find file."<<endl;
system("pause");
return(0);
}

cout<<"Annual Precipitation Report\n\n\n";
cout<<left<<setw(WIDTH1)<<"Weather Station"<<setw(WIDTH1)<<"Elevation"<<setw(WIDTH1)
<<"Precipitation"<<endl;



for(i=0;i<STATION;i++)
{
getline(fin,name,'\t');

fin>>elevation>>jan>>feb>>mar>>apr>>may>>jun>>jul>>aug>>sep>>oct>>nov>>dec;

raintotal = jan+feb+mar+apr+may+jun+jul+aug+sep+oct+nov+dec;


cout<<left<<setw(WIDTH1)<<name<<setw(WIDTH1)<<elevation<<setw(WIDTH1)<<raintotal;

}


system("pause");
return(0);
}






////Check out how the lines after the first ones don't line up. Any help would be appreciated.



I tried pasting the code and it doesnt work. but if you throw it in a compiler you will see what i mean.
Last edited on
Topic archived. No new replies allowed.