clock() - I/O Function
How is "clock()" used in C++?
is an I/O function that returns the amount of time(milliseconds), the calling program is running. To get the value in seconds the it is divided by CLOCKS_PER_SEC. If the time is unavailable it returns "-1".
cout << endl;
cout << "Number of clock ticks is:" << clock();
cout << "Time in Seconds is: " << clock()/CLOCKS_PER_SEC;
Amount of clock ticks: 16
Time in Seconds is: .016
In the above example clock() is used to find the clock ticks elapsed after the program execution. To Convert the time into seconds "CLOCKS_PER_SEC" macro is used.