sscanf 和sprint 64位数据处理

bool CTokenDBInterface::HexStrToTenStr(const char *pHexChar,string &strMac)
{
	ulong64 MacAddr=0;
	string str = "0x";
	str += pHexChar;       //str = "0xaa223344eeff00"
	if(sscanf(str.c_str(),"%I64x"/*"%llx"(MAC下不识别I64)*/,&MacAddr)==-1)//MacAddr对应的十进制数据

		return false;
	char MacBuffer[40]={0};

	sprintf(MacBuffer,"%llu",MacAddr);//把长整型数据存成字符串

	strMac.clear();

	strMac += MacBuffer;

	return true;	
}
bool CTokenDBInterface::TenStrToHexStr(const char *pTenStr,string &strMac)
{
	ulong64 MacAddr=0;
	string str = "";
	str += pTenStr;
	if(sscanf(str.c_str(),"%I64d"/*"%lld"(MAC下不识别I64)*/,&MacAddr)==-1)//把长字符串数据转成长整型数据
		return false;
	char MacBuffer[25]={0};

	sprintf(MacBuffer,"%llx",MacAddr);//把长整型数据以十六进制的格式存储在macBuffer中

	strMac.clear();

	strMac += MacBuffer;

	return true;	
}

2.不区分大小写比较字符串函数:

stricmp  和strcasecmp,,,其中stricmp是strcasecmp的宏定义........!!!!
 
  

你可能感兴趣的:(编程知识)