I'm working on a project where I have to read a date to make sure that it's a valid date. For example, February 29th is only a valid date on leap years, or June 31st is not a valid date, so the computer would output that information based on the input. My issue is that I can't figure out how to parse the string so that the user can enter "05/11/1996" as a date (for example) and then take that and put it into seperate integers. I was thinking about trying to do something with a while loop and string stream, but I'm a little stuck. If someone could help me with this, I would really appreciate it.
If the format is like in your example, you could take out the integer like this:
int day, month, year;
sscanf(buffer, "%2d/%2d/%4d",
&month,
&day,
&year);
where of course in buffer you have the date ("05/11/1996" )