I've made this simple timer/alarm for myself for this game I'm playing. I want to use it to inform me of an automated event a few minutes before it happens. It isn't done yet, but I am concerned with how much resources it takes. From the compiler, it takes about 20% CPU which is disturbing for me since the game itself only takes about 10%.
Again, the code is by all means not yet done but all it takes now is a simple condition. I want to know if there is any way I can make it more efficient.
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main(void){
time_t server_time;
struct tm server;
char server_str[50];
int i = 0, temp, min_temp = 0;
server_time = time(NULL) - (5 * 60 * 60);
server = *(gmtime(&server_time));
strftime(server_str, 50, "%A, %B %d %Y", &server);
temp = server.tm_sec;
while(i == 0){
server_time = time(NULL) - (5 * 60 * 60);
server = *(gmtime(&server_time));
if(temp != server.tm_sec){
system("cls");
printf("SERVER TIME: (%s) (%02d:%02d:%02d)\n", server_str, server.tm_hour, server.tm_min, server.tm_sec);
temp = server.tm_sec;
}
if(server.tm_hour == 7 || server.tm_hour == 15 || server.tm_hour == 23){
//if(server.tm_min > 56){
// min_temp =
//}
}
};
}