Solved programming problem

Use Max and Capacity Function in Vector C++.

Source code

#include <iostream>

#include<vector>

using namespace std;

int main()

{

   vector<int>array;

   int i;

   ///save some value

   for(i=0;i<10;i++)

   {

       array.push_back(i);

   }

   cout<<"
Max: "<<array.max_size();///highest space we can use in this vector

   cout<<"
Capacity: "<<array.capacity(); ///the total space we are using now

   cout<<endl;

    return 0;

}

Output

Max: 1073741823
Capacity: 16

Join the discussion

Add your comment