fork(1) download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. time_t begin_time; //time at the start of the loop
  8. time_t current_time; //time when checking for a one-second interval
  9. double frames = 0; //number of times passed through the loop
  10.  
  11. time(&begin_time); //sets begin_time
  12.  
  13. while (true) //or however you loop your game
  14. {
  15. frames++; //increments frames
  16. time(&current_time); //sets current_time
  17.  
  18. //HERE IS WHERE YOU WOULD PUT YOUR CODE i.e. UPDATING AND DRAWING AND WHATNOT
  19.  
  20. if (difftime(current_time, begin_time) >= 1.0) //if one second has passed since the loop started
  21. {
  22. printf("Frames: %.21f\n", frames); //print the frames run through in one second
  23. frames = 0; //reset frames
  24. time(&begin_time); //resets begin_time
  25. }
  26.  
  27. }
  28. }
Time limit exceeded #stdin #stdout 5s 2680KB
stdin
Standard input is empty
stdout
Standard output is empty