将字符串的前八个字节转换为__int64位整数

__int64 CCtpKernel::ColumnStringToInt64(std::string& strName)
{
	__int64 nRet = 0;
	const char* p = strName.c_str();
	char* s = (char*)&nRet;

	for (int i = 0; i < 8 && *p != '\0'; i++)
	{
		*s = *p;

		p++;
		s++;
	}

	return nRet;
}

你可能感兴趣的:(c/c++)