Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

vectors c++

#include <iostream>
#include <vector>
 
using namespace std;

int main()
{
    // Create a vector containing integers
   vector<int> v = { 7, 5, 16, 8 };
 
    v.push_back(25); // Adds 25 to the contents of the vector 
    v.push_back(13); // Adds 13 to the contents of the vector
 
    // Print out the contents of the vector
    cout << "v = { ";
    for (int n : v) {
        std::cout << n << ", ";
    }
    cout << "}; 
";
}
Source by en.cppreference.com #
 
PREVIOUS NEXT
Tagged: #vectors
ADD COMMENT
Topic
Name
9+2 =