Best way to ask the user for time?

hey guys

im working on a small program and i want to ask the user about departure time and arrival time now what would be the best way to get the time? and by that i mean can i ask the user to enter time like this.... 1AM or 1am. or ofc 1pm or 1PM.
cause i cant really think of a data type other than a string to store that. and if i do use a string for it then how will i do error checking on it?.
Also one more thing how will i keep a 2 hour difference between departure time and arrival time?
You can always get your user input as string and then perform validation on them. If OK convert them to your desired number and proceed as you please.

You can check for example if a number is followed by AM or am, strip the number and convert it to a different type.

Some idea is to use for these issues:
http://www.cplusplus.com/reference/clibrary/cctype/isalpha/
http://www.cplusplus.com/reference/clibrary/cctype/isdigit/
That solved most of my problem i.ll check some things out and reply if anything else is wrong so thanks for now.
Topic archived. No new replies allowed.