how to clear a vector of all elements in c++ code example

Example: clear vs erase vector c++

//Syntax
vectorname.clear()
vectorname.erase(startingposition, endingposition)
  
clear() removes all the elements from a vector container, thus making its 
size 0. All the elements of the vector are removed using clear() function. 
  
erase() function, on the other hand, is used to remove specific elements from 
the container or a range of elements from the container, thus reducing its
size by the number of elements removed.

Tags:

Cpp Example