I want to convert seconds into hours, min and seconds. I was able to test it with a small equation turning seconds into hours but now it returns zeros for every entry. I have tried several ways but I can't seem to figure it out. Can anyone point me in the right direction?
Code:
#include <stdio.h>
void secCount(int *seconds, int *hours, int *min, int *sec);
int main(int argc, const char * argv[])
{
int sec=0, hours=0, min=0, seconds =0;
{
printf("Enter the time in Seconds");
scanf("%d",&seconds);
secCount(&seconds, &hours, &min, &sec);
printf("The time is equal to %d hours %d min and %d seconds", hours, min, sec);
}
return 0;
}
void secCount (int *seconds, int *hours, int *min, int *sec)
{
int days;
int s = 0;
days = *seconds / 86400; // sets total to hours //
s %= 86400; // sends remainder //
*hours = s / 3600; // sets total to min //
s /= 3600; // sends remainder //
*min = s / 60; // gets min //
*sec = s % 60; // sets remanding to sec //
}