D
D
dearname2015-06-06 20:25:57
Arrays
dearname, 2015-06-06 20:25:57

How to create a vector of arrays in C++?

I need to create a vector of arrays. The vector will store references to arrays. I implemented like this:

vector < unsigned char* > array;

   for(int i=0; i<10; i++){
        obj.c_k=obj.sK(obj.c_k,i);
        array.push_back(obj.c_k);
        cout<<"---"<<i<<"----"<<endl;
   }

For some reason, when outputting, it shows that the size of the vector is (10 elements) (as it should be), but all these ten elements are the last array.
i.e. I display for example: array[5] - produces 10 array, array[0] - also 10 array.
what is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2015-06-07
@opium

You push the same entry into the vector:
array_cipher_key.push_back(array);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question