int main()
{
using namespace std;
time_t time1 = 1;
cout << "看数据大小端" << endl;
cout << "时间地址1: " << hex << (uint32_t)((uint8_t*)(&time1)) << " 值:" << hex << (uint32_t)(*((uint8_t*)(&time1))) << endl;
cout << "时间地址2:" << hex << (uint32_t)((uint8_t*)(&time1) + 1) << " 值:" << hex << (uint32_t)(*((uint8_t*)(&time1) + 1)) << endl;
cout << "时间地址3:" << hex << (uint32_t)((uint8_t*)(&time1) + 2) << " 值:" << hex << (uint32_t)(*((uint8_t*)(&time1) + 2)) << endl;
cout << "时间地址4:" << hex << (uint32_t)((uint8_t*)(&time1) + 3) << " 值:" << hex << (uint32_t)(*((uint8_t*)(&time1) + 3)) << endl<<endl;
if (((uint32_t)((uint8_t*)(&time1))) < ((uint32_t)((uint8_t*)(&time1) + 3)))
{
if ((uint32_t)(*((uint8_t*)(&time1)))==1)
{
cout << "时间地址1: " << hex << (uint32_t)((uint8_t*)(&time1)) << " 值:" << hex << (uint32_t)(*((uint8_t*)(&time1))) << endl;
cout << "低地址存放低字节" << endl<<endl;
}
}
}
判断数据大小端
于 2023-02-21 09:46:24 首次发布