• Source
    1. #include<stdio.h>
    2. #include<vector>
    3. #include<string>
    4. using namespace std;
    5. int main()
    6. {
    7. int i; // String type vector is also same
    8. string str="Good line";
    9. vector <string> ve;
    10. ve.push_back(str); // it store at 0 index
    11. ve.push_back("good day"); // it store at 1 index
    12.  
    13. for( i=0; i< ve.size() ; i++ ) // We use size, It return Num of element in Vector
    14. printf(" %s <-\n", ve[i].c_str() );
    15.  
    16.  
    17. ve.pop_back(); // it delete last value
    18. printf(" size %d\n", ve.size());
    19. ve.clear(); // Now ve is empty
    20. return 0;
    21. }