My project for my C++ class requires that I take a bunch of weather data. It's a ton of lines so I won't include all of the text file, but here's a sample of it:
0 943
0 5
0 107
2 401
0 299
The first column is snowfall and the second is total precipitation. I have to find things like mean and median with the data, but that's not an issue as I can do math fine. I just don't know how to input all of that data into an array. I was sick and missed class when they went over this so I'm compeltely lost. Basically what I need is help with
1. creating an array that can intake a ton of lines
2. taking the lines from the text file into an array

Recommended Answers

All 4 Replies

Don't use an array. Use a vector.

Open text file. Fetch int from text file. push_back on the end of the vector. Repeat until done.

I don't know how to do that. That was part of the day I missed and my teacher doesn't have any examples of vectors online.

Does your teacher have the work you missed, online?

Do you know how to search for things on the "internet"?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.