这段代码中的错误是什么? [英] What is the error in this code?

查看:96
本文介绍了这段代码中的错误是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误是:

错误C4996'ctime':此函数或变量可能不安全。请考虑使用ctime_s。要禁用弃用,请使用_CRT_SECURE_NO_WARNINGS。有关详细信息,请参阅在线帮助。



我尝试过:



Error is:
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.

What I have tried:

#include<iostream>
#include<ctime>
using namespace std;
int main()
{
	time_t now = time(0);
	//Convert time to string form
	char *tm = ctime(&now);
	cout << "Time of System is: " << tm << endl;
	system("pause");
	return 0;
}<pre>

推荐答案

这不是错误,而是警告。您使用的是过时的功能(已经已弃用 [ ^ ])它建议更现代的版本: ctime,ctime_s - cppreference.com [ ^ ]

你可以忽略它这样的简单程序,或使用更新的代码。
It's not an error, it's a warning. You are using an outdated function (it's been Depreciated[^] ) and it's suggesting a more modern version: ctime, ctime_s - cppreference.com[^]
You can ignore it for a simple program like this, or use the newer code.


参见ctime_s,_ctime32_s,_ctime64_s,_wctime_s,_wctime32_s,_wctime64_s [ ^ ]。


这篇关于这段代码中的错误是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆