I have read [this](https://stackoverflow.com/questions/4944252/using-memcpy-to-copy-a-structure), [this](https://stackoverflow.com/questions/4932012/copying-one-structure-to-another) and [this](https://stackoverflow.com/questions/4931123/copying-one-structure-to-another) but none of them answers what I like to know

A set of PId's (3 bytes each) are returned from a hardware which is saved into a raw array (`buffer`). This device returns exactly 84 bytes. 

Then I need to copy these PIds to an array or arrays which is readable by API library for this device.

Here is my code

```
#pragma pack (1)
typedef unsigned char PId[3];
typedef PId PIDs[28];

int GetList(PId* plist){

    unsigned char buffer[84];

    //... Reads the data from hardware memory to buffer
    if (RunCMD(0xCD, &buffer)){
        // buffer has the correct data now 'AAAA...'

        memcpy(&plist,buffer, 84);

        printf("%02X%02X%02X\n", buffer[0], buffert[1], buffer[2]); 
        printf("%02X%02X%02X\n", buffer[3], buffer[4], buffer[5]); 

        return 0;
    } 
    return 1;
}

int main(void) {
    ...

    PId plist_a;
    GetList(&plist_a);

    printf("%02X%02X%02X\n", plist_a[0][0], plist_a[0][1], plist_a[0][2]); 
    printf("%02X%02X%02X\n", plist_a[1][0], plist_a[1][1], plist_a[1][2]); 
    ...
}

```

Somehow this code does not copy proper data to `PIDs` array. `buffer` have the proper data but after `memcpy`, `pids` does not have the same data.

I know I'm doing something wrong but I can't find it.

if it helps, I'm compiling my code with windows `GCC` for `ARM CPU`

EDIT: I apologize for confusing everyone, actually the code was working, however I missed a part of code. which I corrected. `pids` is not of type `PIDs` it is a pointer to it.