I want to create a byte array out of an unknown struct and add a number additionally in the front of this byte array. How do I do this?

I currently have this code:

```
template <class T>
void CopterConnection::infoToByteArray(char *&bit_data, size_t *msglen,
                                       T data) {
    // Determine which kind of element is in the array, will change in the final code
    char typeID = -1;

    *msglen = sizeof(data);
    *msglen += 1;  // take in account of typeID

    // Create the pointer to the byte representation of the struct
    bit_data = new char[*msglen];

    // copy the information from the struct into the byte array
    memcpy(bit_data, &data+1, *msglen-1);
    bit_data[1] = typeID;
}

```

But this is not working. I guess I use the memcpy wrong. I want to copy the unkown struct T into the positions `bit_data[1]` to `bit_data[*end*]`. What is the best way to achieve this?