Tip of the Day: Of Vectors and Arrays
by Scott MacDonald on March 16th, 2011
No Comments
STL vectors can act as typical c-style arrays. To cast from vector<T> to T*, simply take the address of the first element.
void myFunction( int* i )
{
std::cout << *i << std::endl;
}
std::vector myVector; myFunction( &myVector[0] );
Categories: C++, Programming, Tip
