Project about timer with laps SOS 😭😭 beginner here

I have a project. The problem is make a timer. When the user hit enter key, the program will display a lap. Help anyone 😭
I'm a beginner.

I have my timer but don't know how to display the laps.

this is my timer:
int a,b,c,d;

for (a=0;a<=59;a++){
for (b=0;b<=59;b++){
for (c=0;c<=59;c++){
for (d=0;d<=59;d++){
cout<<a<<":"<<b<<":"<<c<<":"<<d;}}}}

help please.
closed account (48T7M4Gy)
Please don't make duplicate posts for the same problem.
What's the problem anyway?

I don't know how to display laps whenever ENTER key is pressed.
closed account (48T7M4Gy)
Google 'key press c++'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <ctime>

int main()
{
    const int NLAPS = 20 ;
    std::cout << "press enter to time a lap\n" ;

    for( int lap_number = 0 ; lap_number < NLAPS ; ++lap_number )
    {
        // http://en.cppreference.com/w/cpp/chrono/c/time
        std::time_t start = std::time(nullptr) ; // start of lap timepoint

        char ch = 0 ;
        while( std::cin.get(ch) && ch != '\n' ) ; // wait for user to hit the enter key

        std::time_t end = std::time(nullptr) ; // end of lap timepoint

        // http://en.cppreference.com/w/cpp/chrono/c/difftime
        std::cout << "lap #" << lap_number+1 << " : " << std::difftime( end, start ) << " seconds\n" ;
    }
}
Does it apply with my timer?
I'm having an error with (nullptr)
LOL i'm sorry but you got the wrong idea.
closed account (48T7M4Gy)
So what is the correct idea that you are chasing? The solution above is one of many possibilities and is often machine dependant so that's why you need Dr Google.

This site has an article on it if you like to surf around here.
It's not about the intervals of the key press. its the elapsed time in the timer.

The timer is running. and when you press the enter it will display a time within the timer in a lap.

the timer is on the top.
Topic archived. No new replies allowed.