I have to read in a string from std::cin in my program. The lines from cin are in the format of two numbers followed by a colon, another two numbers followed by a colon, and then a straight line. Then, the same string would be repeated. An example:
00:33:11|22:55:22
and then I would want two ints a and b to be: a = 3311 b = 225522
I'm trying to find the best way to extract the numbers from the first numbers before the straight line and store that into an int, and do the same for the second set of numbers.
I'm a little unfamiliar with c++, but I have thought about making a for loop, storing characters into a char array, and then using atoi on that array. However, I feel that this method is not the most elegant of approaches. Any suggestions to this problem?
thanks