i'm recently start to learning C because i start a course in my university. In one of my lesson I need to write a program that converts a number of in ms to days, hours, minutes, second and milliseconds. I use this source code:
#include <stdio.h>
int main ()
{
long int time_ms;
int d, h, m, s, ms;
printf("insert the value in ms: \n");
scanf("%ld\n", &time_ms);
d = time_ms/(24*60*60*1000); //ms in a day
time_ms = time_ms%(24*60*60*1000); //reminder in ms
h = time_ms/(60*60*1000);
time_ms = time_ms%(60*60*1000);
m = time_ms/(60*1000);
time_ms = time_ms%(60*1000);
s = (time_ms/1000);
ms = time_ms%1000;
printf("%d d %d h %d m %d s %d ms\n",
d, h, m, s, ms);
}
i compling it, and it work, but after i insert the number of milliseconds the shell of MacOs (were i'm working) doesn't print anything until i type "exit". what do i wrong?