|
From: ram.ragu on 31 Jul 2006 03:30 can you tell how to get difference in minutes for two HH:MM:SS times. example, x=10:05:12 y=23:02:01 z=?????(x-y) in min
From: Ulrich Eckhardt on 31 Jul 2006 03:43 ram.ragu(a)gmail.com wrote: > can you tell how to get difference in minutes for > two HH:MM:SS times. > example, > x=10:05:12 > y=23:02:01 > > z=?????(x-y) in min Take a look at the time() and gmtime() functions and the others related to them. If this is a homework question where you are supposed to parse some strings, you should start first with separating the strings into the three numbers and then take their difference numerically. Make sure you read the FAQ, too. Uli -- FAQ: http://ma.rtij.nl/acllc-c++.FAQ.html
From: Richard Heathfield on 31 Jul 2006 03:46 ram.ragu(a)gmail.com said: > can you tell how to get difference in minutes for > two HH:MM:SS times. > example, > x=10:05:12 > y=23:02:01 > > z=?????(x-y) in min Load the first time into a struct tm. Load the second time into a second struct tm. (Hint: read the docs on struct tm to make sure you do this right, and zero any members you don't set.) Pass each struct tm to mktime, and catch the return values. Submit these to difftime, which will return the difference in seconds, expressed as a double. Divide by 60 to get the difference in minutes. -- Richard Heathfield "Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk email: rjh at above domain (but drop the www, obviously)
From: Francis Glassborow on 31 Jul 2006 07:32 In article <1154331047.377518.65710(a)p79g2000cwp.googlegroups.com>, ram.ragu(a)gmail.com writes >can you tell how to get difference in minutes for >two HH:MM:SS times. >example, >x=10:05:12 >y=23:02:01 > >z=?????(x-y) in min > Not really on topic here. However: write a function that converts hrs, mins, seconds to seconds call it for each time find the difference between the return values and divide by 60 -- Francis Glassborow ACCU Author of 'You Can Do It!' and "You Can Program in C++" see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects
|
Pages: 1 Prev: hex decimal to decimal Next: std::istringstream woes ... |