N
Neo
Is there any function in std. C to convert seconds into hour, min and sec. ?
Lets say the following code takes 129 seconds, how do i get components of
time in "hour min and second" format? Is there any std. library function to
do this?
it should give "0 hrs 2 min 9 sec"
/* The following code only prints elapsed time in seconds */
#include<stdio.h>
#include<limits.h>
#include<time.h>
int main(void)
{
time_t t1, t2;
unsigned int i,j, k;
t1 = time(NULL);
/* some code to timed here.... */
/* ..... */
for(i = 0; i < ~0; i++);
/* ... end of processing ... */
t2 = time(NULL);
k = difftime(t2, t1);
printf("Time Elapsed = %d seconds\n", k);
return 0;
}
-Neo
Lets say the following code takes 129 seconds, how do i get components of
time in "hour min and second" format? Is there any std. library function to
do this?
it should give "0 hrs 2 min 9 sec"
/* The following code only prints elapsed time in seconds */
#include<stdio.h>
#include<limits.h>
#include<time.h>
int main(void)
{
time_t t1, t2;
unsigned int i,j, k;
t1 = time(NULL);
/* some code to timed here.... */
/* ..... */
for(i = 0; i < ~0; i++);
/* ... end of processing ... */
t2 = time(NULL);
k = difftime(t2, t1);
printf("Time Elapsed = %d seconds\n", k);
return 0;
}
-Neo