c++ - insert arrays to vector -


I need to write simple code with vectors and I am a little struggling.

I have the buffer array) which is received from any other program data in the callback, I need to insert vector-at the end of the entire array.

  vector & lt; u_char & gt; Vector; Callback (new data inside buffer) {copy buffer at the end of vector; }   

In the end, vector consider to include continuous data from the buffer.

Is there an effective way to do this without inserting four characters with "for"? for (...) vector.push_back [i] = buffer [j]

thanks!

If you know the value, then you can insert a boundary:

  vector.insert (vector.back (), buffer, buffer + size);   

There is also a more general algorithm for this type of thing:

  #include & lt; Iterator & gt; # Include & lt; Algorithm & gt; Std :: copy (buffer, buffer + size, std :: back_inserter (vector));    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -