这在Turbo C ++中运行,但不适用于较新版本的C ++。有什么替代方案吗?
#include<stdio.h>
#include<dos.h>
main()
{
struct date d;
getdate(&d);
printf("Current system date is %d/%d/%d\n",d.da_day,d.da_mon,d.da_year);
return 0;
}
答案 0 :(得分:0)
与getdate
最直接的比喻是time
+ localtime
#include <stdio.h>
#include <time.h> /* time_t, struct tm, time, localtime */
int main ()
{
time_t rawtime;
time ( &rawtime );
tm * const ptm = localtime ( &rawtime );
printf("Current system date is %d/%d/%d\n",
ptm->tm_day,ptm->_mon+1,ptm->tm_year+1900);
return 0;
}
或者,对于更多&#34; C ++&#34;样式方法,查找std::chrono