常用的c_c++代码

#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 ;

}


对传入的不定长的参数进行处理,一般用于打印日志中

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值