locked
how to append one byte array into another

    Question

  • Hi

     Is there any simple way to append byte one array into another byte array in visual c++?

     

    Wednesday, February 16, 2011 12:21 PM

All replies

  • On 16/02/2011 13:21, Nandkumar T wrote:

    Hi

      Is there any simple way to append byte one array into another byte array in visual c++?

    Do you mean this?

    std::vector<BYTE> bytes;
    ...
    bytes.push_back( * some byte value here * );
     Giovanni

    Wednesday, February 16, 2011 12:29 PM
  • On 16/02/2011 13:29, Giovanni Dicanio wrote:

    On 16/02/2011 13:21, Nandkumar T wrote:

    Hi

       Is there any simple way to append byte one array into another byte array in visual c++?

    Do you mean this?

    std::vector<BYTE>  bytes;
    ...
    bytes.push_back( * some byte value here * );

    BTW: if you mean appending a whole byte array to another one, you may want to try something like this:

    std::vector<BYTE> arr1, arr2;
    ...

    arr1.insert( arr1.end(), arr2.begin(), arr2.end() );
     Giovanni

    Wednesday, February 16, 2011 12:32 PM
  • El 16/02/2011 13:21, Nandkumar T escribió:
    > Hi
    >
    > Is there any simple way to append byte one array into another byte array
    > in visual c++?
    >
    If you mean plain C-style arrays (i.e. int MyArray[MY_SIZE]) I'm afraid
    you'll have to do it "by hand" (reserve memory enough to hold both
    arrays, copy them to the new array, then free the old arrays if necessary).
     
    If you are using CArray or similar, you have the Append function to do
    just that.
     
    And if you are using std::vector, which is, BTW, the best option in most
    cases, you have the function insert, as Giovanni has pointed out.
     
    Wednesday, February 16, 2011 1:20 PM