How to start counting time ?

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++;

}


I'm not really sure how to go about this, but maybe this will help?

http://www.cplusplus.com/reference/ctime/time/?kw=time
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.