大小端转换

 *// 两个字节的大小端转换
        short    ShortChangeBytes(short value)
        {
            short            tmp_value;
            uint8_t        *index_1, *index_2;
        
        
            index_1 = (uint8_t *)&tmp_value;
            index_2 = (uint8_t *)&value;
        
        
            *index_1 = *(index_2+1);
            *(index_1+1) = *index_2;
        
        
            return tmp_value;
        }*
    
       
        *//四个字节的大小端转换
        int   IntChangeBytes(int value)
        {
            int            tmp_value;
            uint8_t        *index_1, *index_2;
        
        
            index_1 = (uint8_t *)&tmp_value;
            index_2 = (uint8_t *)&value;
        
        
            *index_1 = *(index_2+3);
            *(index_1+1) = *(index_2+2);
            *(index_1+2) = *(index_2+1);
            *(index_1+3) = *index_2;
        
        
            return tmp_value;
        }*

你可能感兴趣的:(网络)