c++上有个提取时间的函数,但使用时连接出错是怎么回事啊?

来源:百度知道 编辑:UC知道 时间:2024/05/26 13:12:57
我正在编一个 c++的小程序,其中用到一个提取当前时间的函数,我在MSDN中搜到是在Afxwin.h中定义的CTime类中有此函数,我遍了个小程序测试一下这个函数的用法,程序是这样的:
#include<iostream.h>
#include<Afxwin.h>
void main()
{CTime ctime=CTime::GetCurrentTime();
cout<<ctime.GetYear()<<endl;
}
编译通过,但是连接时出现这样的错误:
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/yiyi.exe : fatal error LNK1120: 2 unresolved externals
我想问一下到底是哪出问题了哈,请高手指点一下吧,下星期要验收的,很急哈~

1.project->setting->c++->project option->添加: /MT
2.project->setting->link->project option
->添加: /nodefaultlib:"libcmt.lib"

因为用到了多线程Multithreaded

当然你也可以这么写
#include <cstdlib>

int main()
{
system("date /t");
system("time /t");

system("PAUSE");
return EXIT_SUCCESS;
}