I made this short program in c but whenever i run it my pc's fan starts spinning really fast. Am i doing something in the wrong way or is the time library just cpu intensive somehow? Here is the code:
#include <stdio.h>
#include <time.h>
void delay(int seconds){
int clocks_to_wait = seconds * CLOCKS_PER_SEC;
clock_t time = clock();
while(clock() < time + clocks_to_wait){
}
}
int main(){
while(1){
printf("\r");
printf("-");
delay(1);
printf("\r");
printf("\\");
delay(1);
printf("\r");
printf("|");
delay(1);
printf("\r");
printf("/");
delay(1);
printf("\r");
printf("-");
delay(1);
}
return 0;
}
My guess is that the empty while loop is making the processor go hot? Am i right?
Edit: Problem solved, source: Simple <Time.h> program takes large amount CPU