The below c++ code is an example that how we can print the element from a vector.
#include<iostream>
#include<iterator> // for iterators
#include<vector> // for vectors
using namespace std;
int main()
{
vector<int> ar = { 1, 2, 3, 4, 5 };
// Declaring iterator to a vector
vector<int>::iterator ptr;
// Displaying vector elements using begin() and end()
cout << "The vector elements are : ";
for (ptr = ar.begin(); ptr < ar.end(); ptr++)
cout << *ptr << " ";
return 0;
}
My question is that how we can transform the element from the ptr*, and make it a 1D array?
the elements of the array will depend on the number of elements i get from *ptr.
for example, my output array would be like this:
int array[i] ={ 1, 2, 3, 4, 5};
