So what I wanted to make is a timer that won't do anything for 25 minutes and then play an mp3 file as an alarm. Only solution I've come across is using the sleep() function, but I don't know if it'll cause any problems due to running for 25 minutes (I see it being used for 3 seconds not 25 * 60). I don't if using it for this long is too taxing on the system or inefficient.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
size_t sessions;
puts("Enter number of sessions to work: ");
scanf("%u" , &sessions);
int work_time = 25*60; //25 minutes to seconds
int break_time = 5 *60; //5 minutes to seconds
for(int i = 1 ; i <= sessions ; i++)
{
sleep(work_time);
printf("Have a 5 minute break...You deserve it :)\n");
sleep(break_time);
puts("Break is over, let's get shit done\n\n");
}
//next line isn't probably the best way to do it but it works for now
system("start wmplayer C:\\Users\\me\\Desktop\\myuser\\english\\fartingnoise.mp3");
return 0;
}
Here's my code so far, my main question is about the sleep function but any criticism of my code is welcome.