The basic idea would be to use a std::vector, which grows in size automatically.
Here is a small example. Note: instead of two vectors, it would be better to
create a class with two data members and have one vector of that class.
Code:
#include <vector>
#include <fstream>
using namespace std;
int main()
{
vector<int> field1;
vector<int> field2;
int f1,f2;
ifstream in("your_data.txt");
in.ignore(1000,'\n'); // skip header line
while (in >> f1 >> f2)
{
field1.push_back(f1);
field2.push_back(f2);
}
}
Bookmarks