Home Forums C Programming time input help Reply To: time input help

#3281
Humayan
Participant

could try:
 

/****************************************************************
* File Name : c:programshelpshell.cpp
* Date : November,29,2007
* Comments : new project
* Compiler/Assembler : VC++ 6.0
* Program Shell Generated At: 2:34:45 p.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include
//#include
//#include
//#include
//#include
//#include
using namespace std;

//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@
 void getTime ( int & hours , int & minutes , int & seconds );
//##################################################################################

 //main function ******************************
int main ( )
{
   
    int hours , minutes , seconds;
   
    cout << "Enter a time: ";
    getTime ( hours , minutes , seconds );
    cout << "hours: " << hours << endl;
    cout << "minutes: " << minutes << endl;
    cout << "seconds: " << seconds << endl;
 return 0 ;
}

/******************************* FUNCTION DEFINITION ******************************
 Name : getTime
 Parameters :
  hours a(n) int * ,
  minutes a(n) int * ,
  seconds a(n) int *

 Returns: Void type
 Comments:
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void getTime ( int & hours , int & minutes , int & seconds )
{
    char ch;
   
    cin >> hours;
    cin >> ch;        // get :
    cin >> minutes;
    cin >> ch;        // get :
    cin >> seconds;
 return;
}