Javatpoint Logo
Javatpoint Logo

C++ Vector data()

This function returns a pointer to an array internally used by a vector to store its elements.

Syntax

Consider a vector 'v' and pointer 'p'. Syntax would be:

Parameter

It does not contain any parameter.

Return value

It returns a pointer to an array.

Example 1

Let's see a simple example.

Output:

10 20 30 40 50

In this example, k is the pointer of integer type referring to the elements of a vector.

Example 2

Let's see a simple another example.

Output:

C C++ Java .Net

In this example, k is the pointer of string type referring to the elements of a vector v.

Next TopicC++ Vector




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA