Reading chunks of text from file but not whole file

Is there is a way with ofBuffer(?) to read data from a text file from different points within the file?
it seems you can only load a whole file with the OF functions.


no with ofBuffer you can only read the whole file. if you need to read parts only you can use ofFile directly to skip over the file and read only the parts you need. eg:

ofFile file("somefile");
int a;
file >> a >> std::ws;
int b;
file >> b >> std::ws;
string str;
file >> str >> std::ws;

which reads an integer, skips a space tab or breakline, reads another int, skips another space tab or breakline, reads an string until the next space tab or breakline, skips 20 bytes…

Thanks Arturo - I tried reading like you suggest, but my ints a and b just return zero.( but the file is ok)
I don’t see where the seekg comes from - its not in the offile documentation.
I guess its the position pointer(??)

I really just need to read particular lines of a text file, but offile has no functions to do this as far as I can see.
I can kind of do this with fstream, which just reads word by word.

ifstream myFile; ofToDataPath(“data.txt”).c_str() );
myFile >> strA >> strB;

Maybe I should just use this?

ofFile is also an ifstream so everything you can do with ifstream you can do with ofFile. and yes in order to do this you need to use the methods in ifstream no matter if you use an ofFile or directly an ifstream