#pragma pack(push,1) /* 在这中间定义的结构体,已单字节对齐 */ #pragma pack(pop)
/************************************************************************ 函数功能: 将时间time_t转化为YYYY-MM-DD hh:mm:ss 输入参数: time_t tTime -- 给定时间的标准time_t格式 输出参数: string& strTime -- 字符串 返回值 : 说明 : ************************************************************************/ void time2string(time_t tTime, string& strTime) { struct tm tmTime; localtime_s(&tmTime, &tTime); char cTime[100] = {' '}; _snprintf_s(cTime, sizeof(cTime)-1, "%04d-%02d-%02d %02d:%02d:%02d", tmTime.tm_year + 1900, tmTime.tm_mon + 1, tmTime.tm_mday, tmTime.tm_hour, tmTime.tm_min, tmTime.tm_sec); strTime = cTime; }
/* 用于tcp传输时间结构体 */ typedef struct tagTimePack { unsigned short nYear; unsigned char nMonth; unsigned char nDay; unsigned char nSer; unsigned char nHour; unsigned char nMinute; unsigned char nSecond; std::string toString() { char buff[32] = {'