I have a pointer to an array of bytes (u8). I now have a function that takes a pointer of type int (unsigned int). What is an elegant way to accomplish this without creating a new array and converting each element?
I need to convert each byte to a single int. (i.e. {0x12, 0x34, 0x56} --> {0x00000012, 0x00000034, 0x00000056})
void external_function(unsigned int *val, int length)
{
//Write values to ...
}
void my_function(u8 *array)
{
int length = 10;
//Need to convert *array to (unsigned int *)
external_function(array, length);
}
array[0] = input[0]and so on.external_functiondoes not require all data in one call, you can do this without an array ofintby defining a singleintand iteratively assigning to it one value from the byte array and passing the address of theinttoexternal_functionwith a length of oneint.