The std::vector::data() is an STL in C++ which returns a direct pointer to the memory array used internally by the vector to store its owned elements.
Parameters: The function does not accept any parameters.
Return value: The function returns a pointer to the first element in the array which is used internally by the vector.
Below program illustrate the above function:
The vector elements are: 10 20 30 40 50
- How to store Data Triplet in a Vector in C++?
- vector shrink_to_fit() function in C++ STL
- vector max_size() function in C++ STL
- vector emplace() function in C++ STL
- Passing vector to a function in C++
- vector insert() function in C++ STL
- vector capacity() function in C++ STL
- vector rbegin() and rend() function in C++ STL
- vector::empty() and vector::size() in C++ STL
- vector::front() and vector::back() in C++ STL
- vector::push_back() and vector::pop_back() in C++ STL
- vector :: cbegin() and vector :: cend() in C++ STL
- vector::crend() & vector::crbegin() with example
- vector::begin() and vector::end() in C++ STL
- vector::at() and vector::swap() in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.