Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从C中的小端值构造整数_C_Char_Type Conversion - Fatal编程技术网

从C中的小端值构造整数

从C中的小端值构造整数,c,char,type-conversion,C,Char,Type Conversion,我在C中有几个变量: char*data指向数据的指针(始终在LE中) int-dataStart-data整数开始的偏移量 int-dataLength-包含整数数据的字节数(0尝试一下。当你陷入困境时,以a的形式回答一个特定的问题。字符是应该用数字解释的原始字节,还是字符串?看,数字1234是否对应字节08 D2,D208或49 50 51 52,并且已经确定了这一点,wh否则会阻止您转换为所需的表单吗? int64_t makeint(const char *buff, size_t o

我在C中有几个变量:

  • char*data
    指向数据的指针(始终在LE中)
  • int-dataStart
    -
    data
    整数开始的偏移量

  • int-dataLength
    -包含整数数据的字节数(
    0尝试一下。当你陷入困境时,以a的形式回答一个特定的问题。字符是应该用数字解释的原始字节,还是字符串?看,数字1234
    是否对应字节
    08 D2
    D208
    49 50 51 52
    ,并且已经确定了这一点,wh否则会阻止您转换为所需的表单吗?
    int64_t makeint(const char *buff, size_t offset, size_t offsetinint, size_t len, int minus)
    {
        union
        {
            int64_t i64;
            uint8_t u8[8]
        }d64;
    
        offsetinint = offsetinint & 7;
        memset(&d64, 0, sizeof(d64));
    
        memcpy(&d64.u8[offsetinint], len > (8 - offsetinint) ? (8 - offsetinint) : len, buff + offset);
        d64.i64 *= -1 * !!minus;
        return d64.i64;
    }