How to Print Local Time in C++

Be familiar with some basics of C++., Write these line of codes in your C++ IDE., Compile the program. , Run the output.

4 Steps 1 min read Easy

Step-by-Step Guide

  1. Step 1: Be familiar with some basics of C++.

    Before starting, you can read simple programming articles of LifeGuide Hub about C++:
    How to Learn C++ Programming How to Create a Simple Program in C++ How to Write Standard Code in C++
  2. Step 2: Write these line of codes in your C++ IDE.

    include<windows.h> include<wchar.h> int main (void) { SYSTEMTIME time; while (true) { GetLocalTime(&time); wprintf(L"The Local time: %02d:%02d:%02d\n"

    time.wHour, time.wMinute, time.wSecond); Sleep(1000); system("cls"); } return 0; } ,, It should give you your time!
  3. Step 3: Compile the program.

  4. Step 4: Run the output.

Detailed Guide

Before starting, you can read simple programming articles of LifeGuide Hub about C++:
How to Learn C++ Programming How to Create a Simple Program in C++ How to Write Standard Code in C++

include<windows.h> include<wchar.h> int main (void) { SYSTEMTIME time; while (true) { GetLocalTime(&time); wprintf(L"The Local time: %02d:%02d:%02d\n"

time.wHour, time.wMinute, time.wSecond); Sleep(1000); system("cls"); } return 0; } ,, It should give you your time!

About the Author

M

Margaret Barnes

Committed to making pet care accessible and understandable for everyone.

30 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: