From: Learn By on
http://learnbyexamples.org

Suppose you have a vector of int and function that takes int *. To obtain the address of the internal array of the vector v and pass it to the function, use the expressions &v[0] or &*v.front(). For example:
view plaincopy to clipboardprint?
void func(const int arr[], size_t length );
int main()
{
vector vi;
//.. fill vi
func(&vi[0], vi.size());
}
It’s safe to use &vi[0] and &*v.front() as the internal array’s address as long as you adhere to the following rules: First, func() shouldn’t access out-of-range array elements. Second, the elements inside the vector must be contiguous. Although the C++ Standard doesn’t guarantee that yet, I’m not aware of any implementation that doesn’t use contiguous memory for vectors. Furthermore, this loophole in the C++ Standard will be fixed soon.
http://learnbyexamples.org/cc/c-tip-treating-a-vector-as-an-array.html
From: Jan Simon on
Dear Offtopic poster,

> http://[snip]
.... Furthermore, this loophole in the C++ Standard will be fixed soon.
> http://[snip]/cc/c-tip-treating-a-vector-as-an-array.html

I am very happy that this loophole is fixed in Matlab already.
I do have the impression, that you want users to click on the link you have posted two times. I won't do this.

Jan