I am trying to write a program that asks the user to enter a time of beginning, and a time of ending, and uses these times to calculate a price. How do I write a program that realizes a clock like that? I am stumped as to what to do, any help would be greatly appreciated.
Try #include <stdlib.h>. Using that, you can convert strings to floating point integers.
Then, request the times to be input in a certain format. From there, check for certain characters in certain places in the input (an array), like PM at the end of the string, a colon as the second character, etc. Convert these to something atof() can actually use (if there is a PM, add 12, replace the semicolon with a decimal point). Be sure to store this value in a float.
the other thing you can do is ask for 2 dates and 2 hours/minutes/seconds store the data in double or float ( like day1 day2 month1 month2 year1 year2 hour1.....) and calculate the time betwean the two points in time. you just ned to be shure to add one minute if the number of seconds goes over 60 etc...
it should be very easy