I have a txt file with this format:
<Year> <count>
1999 5.4
1989 5
1993 55.4
I have to get each year and count from the file, convert the year in to int
and count in to double
and store them in arrays.
Problem: it shows random huge negative numbers
stringstream line;
string a;
int year;
double count;
ifstream myfile(path);
if (myfile.is_open())
{
getline(myfile, a); //getting rid of the first line.
while (getline(myfile, a))
{
cout << a << '\n';
line >> year >> count;
cout << "year:" << year << endl;
cout << "count:"<< count << endl;
}
myfile.close();