asctime_s  asctime

// rand随机数.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
// #include "pch.h"
#include <iostream>
#include<ctime>
using namespace std; int main()
{
std::cout << "Hello World!\n"; time_t now = time(0);
char* dt = ctime(&now); cout << "本地日期和时间:" << dt << endl; tm *gmtm = gmtime(&now);
dt = asctime(gmtm);
cout << "UTC 日期和时间:" << dt << endl; return 0; } // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单 // 入门提示:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件

  

1>------ 已启动生成: 项目: rand随机数, 配置: Debug Win32 ------
1>rand随机数.cpp
1>d:\dzpk\cpp1\rand随机数\rand随机数\rand随机数.cpp(37): error C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\time.h(476): note: 参见“ctime”的声明
1>d:\dzpk\cpp1\rand随机数\rand随机数\rand随机数.cpp(41): error C4996: 'gmtime': This function or variable may be unsafe. Consider using gmtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\time.h(496): note: 参见“gmtime”的声明
1>d:\dzpk\cpp1\rand随机数\rand随机数\rand随机数.cpp(42): error C4996: 'asctime': This function or variable may be unsafe. Consider using asctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>c:\program files (x86)\windows kits\10\include\10.0.17763.0\ucrt\time.h(117): note: 参见“asctime”的声明
1>已完成生成项目“rand随机数.vcxproj”的操作 - 失败。
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

05-11 14:05