#include <iostream>
#include <fstream>
int main()
{
std::ifstream f("list.txt");
int a;
int b;
int c;
int arr[4];
std::string unnecessary;
f >> unnecessary;
f >> a;
f >> unnecessary;
f >> b;
f >> unnecessary;
f >> c;
f >> unnecessary;
for (int i = 0; i < 4; i++)
f >> arr[i];
{
usingnamespace std;
cout << a << endl
<< b << endl
<< c << endl
<< arr[0] << " "
<< arr[1] << " "
<< arr[2] << " "
<< arr[3] << endl;
}
return 0;
}
Notice the "unnecessary" string that I have. I do this for each line so that it "skips" over that part and then can read the number.
Is there an easier way to do this, something to make it so it automatically only reads the second clump of information on each line? It might not seem like a big deal right now, but for this big file header stuff I'm working with, it makes it really tedious.
Heh, so saving a stream line in a string and then using a stringstream on the string to treat it as a stream again. That could work, I'll try to use it, but if not I guess it isn't too big of a deal. Thanks! (For some of the stuff where it doesn't make sense to put it into an array, I'll just have to use a string called "u" ;] )