how to cast uint8_t array of 4 to uint32_t in c
c, casting
Solution
Given the need to get uint8_t values to uint32_t, and the specs on in4_pton()...
Try this with a possible correction on the byte order:
uint32_t i32 = v4[0] | (v4[1] << 8) | (v4[2] << 16) | (v4[3] << 24);
Problem
I am trying to cast an array of uint8_t to an array of uint32_t, but it seems not to be working. Can any one help me on this. I need to get uint8_t values to uint32_t. I can do this with shifting but i think there is a easy way. ``` uint32_t *v4full; v4full=( uint32_t *)v4; while (*v4full) { if (*v4full & 1) printf("1"); else printf("0"); *v4full >>= 1; } printf("\n"); ```