有一个关于时间小程序,编译连接时提示:
正在编译...
1>cgtest.cpp
1>.\cgtest.cpp(9) : warning C4996: “localtime”被声明为否决的
1> C:\Program Files\Microsoft Visual Studio 8\VC\include\time.inl(114) : 参见“localtime”的声明
1> 消息:“This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.”
程序如下:
- C/C++ code
#include "stdafx.h"#include <ctime>using namespace std;int main(){ cout<<"hello world!!!"<<endl; time_t t; time(&t); tm *pt=localtime(&t); printf("%s",pt->tm_year);}
stdafx.h的内容如下:
- C/C++ code
#include <stdio.h>#include <iostream>#include <tchar.h>
请问什么原因?
------解决方案--------------------------------------------------------
_localtime32