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.
Step-by-Step Guide
-
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++ -
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! -
Step 3: Compile the program.
-
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
Margaret Barnes
Committed to making pet care accessible and understandable for everyone.
Rate This Guide
How helpful was this guide? Click to rate: