taeyounkim LOG
pointer practice 5 (function that prints how much time passed since midnight) 본문
Career&Study/Coding Practice
pointer practice 5 (function that prints how much time passed since midnight)
taeyounkim 2021. 7. 8. 23:15728x90
#include <stdio.h>
void split_time(long total_sec, int *hr, int *min, int *sec);
int main()
{
int i, j, k;
split_time(1203, &i, &j, &k);
printf("%dhrs %dmin %dsec\n", i, j, k);
return 0;
}
void split_time(long total_sec, int *hr, int *min, int *sec)
{
*sec = total_sec % 60;
int a = (total_sec - *sec) / 60;
*min = a % 60;
*hr = (a - *min) / 60;
}
728x90