The usual method is to use something like fscanf() [1], but if you don't know what format the data is in, then you will have to use more complicated methods.

[1] If you want to ensure safety against incorrectly formed files, use fgets() and then sscanf() on the input, or even better, strtol(), strtod() to convert the numbers.

Edit: my answer is more applicable for C than C++, in C++ stringstream corresponds to sscanf() [roughly], and will do the job for you.

--
Mats