How to start counting time ?
Apr 7, 2013 at 3:01am UTC
Hey , I want to know if there is a function or library that starts counting time when the program starts. Because I'm making a program that is dependent on time.
Pseudo code
time starts
1 2 3 4 5
if ( seconds % 2 == 0 )
{
counter++;
}
Apr 7, 2013 at 5:15am UTC
Apr 7, 2013 at 6:31am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <chrono> // C++11
int main()
{
using namespace std::chrono ;
auto start = steady_clock::now() ;
std::cout << "enter a char " ;
char c ;
std::cin >> c ;
auto end = steady_clock::now() ;
std::cout << "that took " << duration_cast<milliseconds>(end-start).count()
<< " milliseconds\n" ;
}
Topic archived. No new replies allowed.