#include <iostream>
#include <time.h>
int main()
{
time_t curtime=time(0);
tm tim =*localtime(&curtime);
int day,mon,year;
day=tim.tm_mday;
mon=tim.tm_mon;
year=tim.tm_year;
std::cout<<year+1900<<"年"<<mon+1<<"月"<<day<<"日"<<std::endl;
system("pause");
return 0 ;
#include <time.h>
int main()
{
time_t curtime=time(0);
tm tim =*localtime(&curtime);
int day,mon,year;
day=tim.tm_mday;
mon=tim.tm_mon;
year=tim.tm_year;
std::cout<<year+1900<<"年"<<mon+1<<"月"<<day<<"日"<<std::endl;
system("pause");
return 0 ;
}
对传入的不定长的参数进行处理,一般用于打印日志中
writelog(char *format,...)
{
va_list args;
char buf[4096];
memset(buf,0,4096);
va_start(args, format);
vsprintf_s(&buf[strlen(buf)], 4096, format, args);
va_end(args);
string strResult(buf);
..... /以下进行其它的处理
}
//A,B类互相引用的方式
A.h 文件中:
class B; /注意A.h 不可以包含B.h
....
void fun(B *pB) ;
/end of A.h
/A.cpp 文件中:
#include "B.h"
void fun(B *pB)
{ ....};
... /end of A.cpp
//B.h 文件中
#include "A.h"
A *m_pA;
.....
/end of B.h
//B.cpp 文件中
#include "B.h"
....
m_pA = xxxx;
///end of B.cpp