If you have an input file which consists of multiple lines like this: 1. Oliver, 42, 405023, 12
then the most obvious approach is to read an entire line in one go into a string. Then use a stringstream to parse the line into individual words. And having already used stringstream once, it seems a small step to use it again to convert the string to int.