I am having troubles picking apart a string. I don't know how exactly to take it apart to convert a date. They have to enter a date in this form: 03/05/13 or 3/5/13. The program would have to convert it to the format May 5, 2013. I am just having troubles breaking it up into groups. Help would be appreciated.
http://ideone.com/1LaoUV
I guess this works by magic; trying to read the integers with the / after them should put the stream into an error state, shouldn't it? I thought the only delimiters were white space and new lines?
No, because it was able to extract a number before the character. The extraction will stop when it encounters a non-numeric character. It will only error if the first character is not a number.
By the way since the variables are integers a decimal point would also stop the processing. So a string like "3.3.33" should still produce 3 valid integers.
The only justification I offer for my code is that it was successfully tested before I posted it. There may be theoretical objections, that's a separate matter.