-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.cpp
More file actions
31 lines (25 loc) · 712 Bytes
/
timer.cpp
File metadata and controls
31 lines (25 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
int lineCount = 0;
while (lineCount < 50)
{
char command;
do
{
std::cin >> command;
} while (command != 's');
// Get the current time
auto currentTime = std::chrono::system_clock::now();
std::time_t currentTime_t = std::chrono::system_clock::to_time_t(currentTime);
// Print the current time
std::cout << "Current time: " << std::ctime(¤tTime_t) << std::flush;
// Increment the line count
lineCount++;
// Sleep for 30 seconds
std::this_thread::sleep_for(std::chrono::seconds(30));
}
return 0;
}