I have a vector of byte which I wanted to store different types of data to it. I have defined that vector as packed\_data which you can see it in the following member function of my class.

Now I wanted to get different type of data with the PackedData member function and then append those information to the raw\_data vector as byte.

```
// Here I initialize a single vector with the vectors value

std::vector<BYTE> PackedData()
{
    std::vector<BYTE> packed_data;

    // Here I have initialized the header with two byte
    packed_data.insert(packed_data.end(), m_header.begin(), m_header.end());

    // I specified encoding of the packet
    packed_data.insert(packed_data.end(), m_messageEncoding);

    // I specified message type
    packed_data.insert(packed_data.end(), m_messageType);

    // I specified size of payload should send to the server
    packed_data.insert(packed_data.end(), m_messageSize);

    // I specified payload itself must send to the server
    packed_data.insert(packed_data.end(), m_payload.begin(), m_payload.end());

    // I specified footer 
    packed_data.insert(packed_data.end(), m_footer.begin(), m_footer.end());

    return packed_data;
}

```

I haven't any problem to add vector to the packed\_data but When I wanted to store size of my message (it has unsigned int data type) to the vector of bytes as a 4 byte entity, I couldn't get correct data from the vector.

For example, when I pass 512 (decimal value) as an input for m\_messageSize (unsigned int), it just append one byte to the packed\_data vector (0x20 for example).

In the following section, also you can see constructor of my class which I am going to initialize my member fields there:

```
CRawData(MessageType arg_message_type, MessageEncoding arg_encoding, unsigned int arg_total_size, std::vector<BYTE> arg_payload)
{
    // Header Initialization
    m_header.push_back(0xAA);
    m_header.push_back(0xAA);

    // Send / Request / Verification Specifier
    m_messageType = arg_message_type;

    // Encoding Specifier
    m_messageEncoding = arg_encoding;

    // Number of chunks should sent
    m_messageSize = arg_total_size;

    // Payload initialization
    m_payload = arg_payload;

    // Footer specifier
    m_footer.push_back(0xFF);

m_footer.push_back(0xFF);
}

```

Indeed I wanted to append something like 00 00 20 00 to my vector. How can I manage this goal? If more information you need, please request in comment which I can edit my question to the right way.