its all clear now. i was comparing a vector to an array but these seem to be 2 diffrent things.
this is my final program i made with your info's
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;
}
catch (std::bad_alloc &memoryAllocationException )
{
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";
}
}
}
/****************************************************************************/
/****************************************************************************/