views:

261

answers:

2

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

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

A: 

Well, you can convert a vector to a const pointer-to-array using the c_str() member function.

EDIT: Oops! I meant &vec[0]. It's been a long day.

rlbond
I think this only applies to strings..
int3
vector doesn't have a c_str()
Naveen
+8  A: 

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

int3
Actually, yes. That is what I'm looking for. I didn't think to try that. thanks!
tim
+1 for figuring out what the OP wanted oO
Matthieu M.