Guest User

Time class

a guest
May 21st, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. istream& operator>> (istream& in , Time &t)
  2. {
  3.   char startTime[80];
  4.   char endTime[80];
  5.   char *ptr
  6.   int hour, minute;
  7.  
  8.   cout<<"Start time >> ";
  9.   in>>startTime;
  10.   ptr = strtok(startTime, ":");
  11.   hour = atoi(ptr);
  12.   while (hour > 12 || hour < 1)
  13.   {
  14.     cout<<"Hour must be between 1 and 12."<<endl;
  15.     cout<<"Format of time is hh:mm PM or hh:mm AM."<endl<<endl;
  16.     cout<<"Time >> ";
  17.     in>>startTime;
  18.     ptr = strtok(startTime, ":");
  19.     hour = atoi(ptr);
  20.   }
Advertisement
Add Comment
Please, Sign In to add comment