c++读取系统时间再赋值
三个变量year,month,day.如何读取系统时间后再把值分别赋给year,month和day.在线等。谢谢logo0775,朋友你的代码,最后也有问题啊。month...
三个变量year,month,day.如何读取系统时间后再把值分别赋给year,month和day.在线等。谢谢
logo0775,朋友你的代码,最后也有问题啊。month和year的变量赋的值不对啊。 展开
logo0775,朋友你的代码,最后也有问题啊。month和year的变量赋的值不对啊。 展开
3个回答
展开全部
//不好意思,忘了.
#include <iostream>
#include <ctime>
using namespace std;
int main(int argc, char* argv[])
{
tm *year;
tm *month;
tm *day;
time_t t;
t = time(0);
year = localtime(&t);
month = localtime(&t);
day = localtime(&t);
cout<<(year->tm_year+1900)<<endl//返回的是今年减1900,所以要加上1900
<<(month->tm_mon+1)<<endl//因为Month (0 – 11; January = 0),所以要加1
<<day->tm_mday<<endl;
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main(int argc, char* argv[])
{
tm *year;
tm *month;
tm *day;
time_t t;
t = time(0);
year = localtime(&t);
month = localtime(&t);
day = localtime(&t);
cout<<(year->tm_year+1900)<<endl//返回的是今年减1900,所以要加上1900
<<(month->tm_mon+1)<<endl//因为Month (0 – 11; January = 0),所以要加1
<<day->tm_mday<<endl;
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//不好意思,忘了.
#include
<iostream>
#include
<ctime>
using
namespace
std;
int
main(int
argc,
char*
argv[])
{
tm
*year;
tm
*month;
tm
*day;
time_t
t;
t
=
time(0);
year
=
localtime(&t);
month
=
localtime(&t);
day
=
localtime(&t);
cout<<(year->tm_year+1900)<<endl//返回的是今年减1900,所以要加上1900
<<(month->tm_mon+1)<<endl//因为Month
(0
–
11;
January
=
0),所以要加1
<<day->tm_mday<<endl;
return
0;
}
#include
<iostream>
#include
<ctime>
using
namespace
std;
int
main(int
argc,
char*
argv[])
{
tm
*year;
tm
*month;
tm
*day;
time_t
t;
t
=
time(0);
year
=
localtime(&t);
month
=
localtime(&t);
day
=
localtime(&t);
cout<<(year->tm_year+1900)<<endl//返回的是今年减1900,所以要加上1900
<<(month->tm_mon+1)<<endl//因为Month
(0
–
11;
January
=
0),所以要加1
<<day->tm_mday<<endl;
return
0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
void GetSystemTime(
LPSYSTEMTIME lpSystemTime
);
LPSYSTEMTIME lpSystemTime
);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询