Hi guys,

Can you please help understand how this pointer typecast of data_in array works?

Function prototype:

Code:
nrf_ringbuf_cpy_put(nrf_ringbuf_t const * p_ringbuf, uint8_t const* p_data, size_t * p_length);
Code:
int16_t data_in[] = {1050, 1051, 1052};
size_t len_in = sizeof(data_in);

nrf_ringbuf_cpy_put(&m_ringbuf, (int8_t *)data_in, &len_in);
data_in[] is type of int16_t while the function prototype receives as a parameter uint8_t const* p_data. So when calling nrf_ringbuf_cpy_put it typecasts data_in from int16_t to int8_t*

However I do not understand why that works... I mean if you typecast from int16_t to int8_t* you won't lose one byte of information?

Could you provide an example to understand how that works?