即我想知道如何得出下个月的今天?
解决方案 »
- 高手救救:CFile操作输出?是怎么回事
- 公司需求类似qq的聊天软件,最好能和p2p相结合的软件源代码,价格面议
- 简单的问题,在线等....
- 模板类怎样序列化?
- 后台运行的程序怎样获得当前窗口的消息?
- 如何使用VC实现对硬盘序列号的读取!
- 问一个简单的问题:如何在程序中改变一个文件的文件名
- 关于宏的菜鸟问题?
- VC中双击新控件的时候弹出can not add new number,求大侠支招!
- 关于VC读取数据文件,然后画出图形
- 老乡告诉我: c的编译器是是用java写的,java的编译器是用c#写的,c#的编译器是用delphi写的
- 求助,哪位用过MSN的桌面搜索接口ISearchDesktop
operator + – Add and subtract CTimeSpan and CTime objects.
/* The example takes a number of days
* as input and returns the time, the current
* date, and the specified number of days.
*/#include <time.h>
#include <stdio.h>int main( void )
{
struct tm when;
__time64_t now, result;
int days; _time64( &now );
when = *_localtime64( &now );
printf( "Current time is %s\n", asctime( &when ) );
days = 20;
when.tm_mday = when.tm_mday + days;
if( (result = _mktime64( &when )) != (time_t)-1 )
printf( "In %d days the time will be %s\n",
days, asctime( &when ) );
else
perror( "_mktime64 failed" );
}
Sample Output
Current time is Tue Feb 12 09:57:44 2002In 20 days the time will be Mon Mar 04 09:57:44 2002
int day = tm.GetDay();
CTimeSpan ts = CTimeSpan(day,0,0,0);
tm += ts;