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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- How to store Data Triplet in a Vector in C++?
- vector capacity() function in C++ STL
- vector insert() function in C++ STL
- 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 rbegin() and rend() function in C++ STL
- vector :: cbegin() and vector :: cend() in C++ STL
- How to flatten a Vector of Vectors or 2D Vector in C++
- vector::push_back() and vector::pop_back() in C++ STL
- vector::empty() and vector::size() in C++ STL
- vector::front() and vector::back() 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
- Can we access private data members of a class without using a member or a friend function?
- Vector in C++ STL
- How does a vector work in C++?
- Modifiers for Vector 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 email@example.com. 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.