C/C++ Arena

Step 1 of 6

Parsing with istringstream

A std::istringstream turns a string into an input stream, so everything you know about std::cin works on it:

std::istringstream in("12 7 30");
int a, b, c;
in >> a >> b >> c;

The stream converts to false once a read fails, so while (in >> x) reads until the data runs out or hits something that isn't a number. The most common pattern is to read a whole line with std::getline, then parse that line on its own.

Your turn: each input line holds a player name followed by some round scores (possibly none). For each line print NAME TOTAL.

Next: Formatting tables with iomanip