If a function returns me a pointer to a uint8_t array of dynamic/unknown size, how can I fill up my local array using that pointer?
uint8_t * func(void){
uint8_t bs[] = {0x34, 0x89, 0xa5}; //size is variant
return bs;
}
void main(void){
uint8_t * p;
static uint8_t myArr[10]; //size is always greater than what's expected from p
p = func();
}
How can i use p to fill up myArr which could be of different sizes at different calls? Is this possible to determine the size of the array, p is pointing to?
Please excuse my very little experience with programming! Thanks.