C ++ vector for pointer pointers

Is there a way to convert a vector to a pointer to a pointer (ptr-to-ptr).

Background: I have an arbitrary set of data stored in a vector. But I have a library of algorithms that accept ptr-to-ptr (for accessing an array of images). I need to get data from my vector in ptr-to-ptr. How is this possible?

+3
source share
2 answers

If you have a function void f(int **array)and a vector std::vector<int*> vect, you can call f as follows: f(&vect[0]). Is this what you were looking for?

+11
source

Well, you can convert a vector into a const pointer into an array using a member function c_str().

EDIT: ! &vec[0]. .

0

Source: https://habr.com/ru/post/1722077/


All Articles