I'm a beginner having trouble with a common issue. I'm trying to read standard input line by line in C++ wherein each line is [integer][comma][integer]. For example:
1,1
2,3
12,5
etc. I want to only use the integers in each line and assign them to separate variables. The part of my code that's hassling me looks something like this:
int x,y;
for (string line; getline(cin, line); ) {
// ...want to have something like
// x = first integer, y = second integer
// process x and y
}
So essentially, I don't care about storing the values for the integers on each line, but I do want to process each pair of integers to compare them or whatnot.
I've noticed other solutions that use vectors, stringstream, tokens and/or delimiters, but those were almost always for input lines with multiple delimiters per line - here we only have 1 per line, so I thought there might be a more simple solution.
Thanks for your time and patience.