C: storing a void pointer function in a char array with strcpy

49 views Asked by At

I use a function

void * getCapabilities(...)

that returns other functions, depending on the given parameter.

Those functions can have different return types, hence, why I return void *. On of those functions is as follows:

void * getPeripherals(){
    UInt8 periphs[] = {21,22,23,24,25,26};
    return periphs;
}

I'd like to store this in a char array like so:

char cap_periph[7];
strcpy(cap_periph,  (char *)getPeripherals());
print("[CL] res_device_capabilities_get_handler. cap_periph[0] %u  cap_periph[5] %u \n", cap_periph[0],cap_periph[5]);

However, what is printed is bogus (85 and 0, respectively).

I am doing something wrong, but unsure of what. Can you help?

0

There are 0 answers