Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

remove elements from vector

#include<iostream>
#include<vector>
using namespace std;
int main(){
  //Creation of integer vector
  vector<int> vectorArray ;
  for(int i=1;i<10;i++){
  	vectorArray.push_back(i);
  }
  //vector elements are 1,2,3,4,5,6,7,8,9
  
  vectorArray.pop_back();
  for(int i=0;i<vectorArray.size();i++){
  	cout<<vectorArray[i]<<" ";
  }
  //vector elements are 1,2,3,4,5,6,7,8
  cout<<endl;
  
  vectorArray.clear();
  // No elements are left in vector array
  
  return 0;
}
Source by iq.opengenus.org #
 
PREVIOUS NEXT
Tagged: #remove #elements #vector
ADD COMMENT
Topic
Name
2+4 =