1、利用系统函数,不仅可以查看系统时间,而且还能修改系统时间

1 #include<stdlib.h>
2 #include<iostream>
3 using namespace std;
4 void main()
5 {
6     system("time");
7     cin.get();
8     cin.get();
9 }

2、利用Windows API,可以精确到毫秒

 1 #include <windows.h> 
 2 #include <iostream>
 3 using namespace std;
 4 
 5 int main(void)
 6 {
 7     SYSTEMTIME sys;
 8     GetLocalTime(&sys);
 9     cout << sys.wYear << "" << sys.wMonth << "" << sys.wDay
10         << "" << sys.wHour << ':' << sys.wMinute << ':'
11         << sys.wSecond + 0.001 * sys.wMilliseconds << endl;
12     getchar();
13     return 0;
14 }

 

作者:耑新新,发布于  博客园

转载请注明出处,欢迎邮件交流:zhuanxinxin@aliyun.com

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-12-22
  • 2021-12-22
  • 2021-10-05
  • 2021-10-27
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案