Home › Forums › C Programming › time input help
- This topic has 1 reply, 2 voices, and was last updated 17 years, 1 month ago by Humayan.
Viewing 1 reply thread
- AuthorPosts
- November 20, 2007 at 12:21 pm #2037malynParticipant
hi guys,
I am making a program in which I have to enter start date and time and stop date and time in format like 01:05:07 15:26:57
i don’t know how to get that value from the user in hh:mm:ss format and calculate the difference between different inputs. i have no clue of that. could you guys give me some tips on that?
- November 29, 2007 at 1:45 pm #3281HumayanParticipant
could try:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455/****************************************************************<br />* File Name : c:programshelpshell.cpp<br />* Date : November,29,2007<br />* Comments : new project<br />* Compiler/Assembler : VC++ 6.0<br />* Program Shell Generated At: 2:34:45 p.m.<br />=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /><br />#include <br />//#include <br />//#include <br />//#include <br />//#include <br />//#include <br />using namespace std;<br /><br />//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@<br />void getTime ( int & hours , int & minutes , int & seconds );<br />//##################################################################################<br /><br />//main function ******************************<br />int main ( )<br />{<br /><br />int hours , minutes , seconds;<br /><br />cout << "Enter a time: ";<br />getTime ( hours , minutes , seconds );<br />cout << "hours: " << hours << endl;<br />cout << "minutes: " << minutes << endl;<br />cout << "seconds: " << seconds << endl;<br />return 0 ;<br />}<br /><br />/******************************* FUNCTION DEFINITION ******************************<br />Name : getTime<br />Parameters :<br />hours a(n) int * ,<br />minutes a(n) int * ,<br />seconds a(n) int *<br /><br />Returns: Void type<br />Comments:<br />++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br />void getTime ( int & hours , int & minutes , int & seconds )<br />{<br />char ch;<br /><br />cin >> hours;<br />cin >> ch; // get :<br />cin >> minutes;<br />cin >> ch; // get :<br />cin >> seconds;<br />return;<br />}
- AuthorPosts
Viewing 1 reply thread
- The forum ‘C Programming’ is closed to new topics and replies.