#include #include #include /* This function converts char array (little endian) to integer * For example: {0xCA, 0xFE, 0xBA, 0xBE} -> 0xBEBAFECA -> 3199925962 * I'm a bad programmer, so here is workaround: * You need to specify length of char array by second function argument * Kill me :( */ int hex_to_dec (const unsigned char input[], const unsigned int count) { unsigned int sum; for (int i = count; i >= 0; i--) { unsigned int tmp = (int) input[i] * (int) pow (16, i * 2); sum += tmp; } return sum; } int main() { const unsigned char address[4] = {0x00, 0xF8, 0x1E, 0x12}; printf("%u\n", hex_to_dec(address, 4)); return 0; }