1. ## allocating a vector?

my question is, how can i allocate a vector of ints?
ive tried several options like

Code:
```int *ptr;
int elements = 10
ptr = new vector<int> [elements];```
but that doesnt work

2. To create a vector of 10 ints, all set to 0:
Code:
`std::vector<int> elements(10);`

3. yes, but i want a dynamic vector, like this:

Code:
```int choise ;
int *ptr ;
cin  >> choise;
ptr = new int [choise];```
but with a vector instead of an array

ah ........ i just figured out that vector isnt a build in type.. im sorry!
but i still dont know how to allocate

4. but i want a dynamic vector
A vector is a dynamic array. You might want to read SGI's Standard Template Library Programmer's Guide on vectors, or read cppreference.com's entry on vectors.

Your example might be written using vectors as:
Code:
```std::vector<int> choices;
int choice;
cin  >> choice;
choices.push_back(choice);```

5. k ty

6. You should never want to create a dynamic anything. If you are forced to, e.g. when you want to create an array that is based on the size of some user input, then you have to take care of deleting your creation.

Vectors take care of everything for you. They grow to whatever size you need, and you're not burdened with the responsibility of deleting them.

You can certainly get a pointer to a vector if, say, you want to pass the vector to a function:
Code:
```void someFunc(vector<int>* vec)
{
vector<int>::iterator iter = vec->begin();
while(iter != vec->end())
{
cout<<*iter<<endl;
++iter;
}
}

int main()
{
vector<int> v;
v.push_back(3);
v.push_back(-2);

vector<int>* ptr = &v;
someFunc(ptr);

return 0;
}```

7. Of course, the use of a pointer to a vector as in 7stud's example is not actually advisable since someFunc() could take a (const) reference instead, or have an iterator pair passed to it (or have a generic algorithm used in place of it, for that matter).

8. ## tnx guys

its all clear now. i was comparing a vector to an array but these seem to be 2 diffrent things.

Code:
```#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <new>
#include <vector>
#include <ctime>

/* FUNCTION PROTOTYPES */
/****************************************************************************/
void Announcement  ();
void GetInput      (std::vector <int> &);
void Fillvector    (std::vector <int> &);
void Printvector   (std::vector <int> &);

//___________________________________________

/****************************************************************************/

int main ()
{
std::vector <int> arr ;
Announcement  (); // printing announcements.
GetInput      (arr); // getting the Array size.
Fillvector    (arr); // filling the Array with random numbers
Printvector   (arr); // print a vector.
}

/* FUNCTION BODIES */
/****************************************************************************/
/****************************************************************************/
void Announcement ()
{
std::cout <<"Copyright @ Epidemic corperation z0mG .\n\n";

}
/****************************************************************************/
void GetInput      (std::vector <int> &arr)
{
long unsigned    Count = 0;
int    Check = 0;
std::string Safe  = "\0";
std::cout <<"\nHowmany items do u want in your vector?"<< std::endl;
std::cin  >> Count;
std::cin.clear();

while (Check != 1  )
{
try
{

arr.resize(Count);
std::cout <<"Allocated "<< Count << " items with Succes!"<< std::endl;
Check = 1;
}
{
std::cin.clear();

std::cerr <<"Exception occurred:"<< std::endl;
std::cerr << memoryAllocationException.what() << std::endl;
std::cerr <<"you do not have enough memory, please pick a smaller size\n"<<std::endl;

std::cin >> Count;

}
}

}
/****************************************************************************/
void Fillvector (std::vector <int> &arr)
{
unsigned int minimum = 0;
unsigned int maximum = 0;
std::cout <<"Please enter the range where-in the generator will produce\n"
<<"\"RANDOM\" numbers." << std::endl;
std::cin  >> minimum;
std::cin  >> maximum;

std::srand (std::time(0));
for (unsigned int x = 0; x<arr.size(); x++)
{
arr[x] = std::rand () % maximum + minimum;
}
}
/****************************************************************************/
void Printvector (std::vector <int> &arr)
{

for (unsigned int x = 0; x < arr.size(); x++)
{
std::cout <<"\t"<<arr[x];
if (x % 10 == 0 )
{
std::cout <<"\n";
}
}
}

/****************************************************************************/

/****************************************************************************/```

9. Why did you include sstream and new ?