visual c++ - Simple time tracker in C++ -
this question has answer here: c++ calculating time intervals 5 answers im new c++ , wondering how go implementing simple timer keeps track of how time has passed while program running. eg how know when 300 seconds has passed? #include <time.h> clock_t t1,t2; t1 = clock(); //your code here t2 = clock(); //time taken running code segment double time_dif = (double)(t2 - t1)/clocks_per_sec; actually t1-t2 gives number of total clock cycles during execution, divide clocks_per_sec actual time