print vectors code example
Example 1: c++ print elements of vector to the console
#include <iostream>
#include <vector>
int main()
{
std::vector<int> myVector = {1, 2, 3, 4, 5, 6};
for(int i = 0; i < myVector.size(); i++)
{
std::cout << myVector[i] << std::endl;
//***** alternate method *******
//std::cout << myVector.at(i) << std::endl;
}
}
Example 2: cpp vector structure
#include <vector>
typedef struct test1 {
int a;
char b;
} TOTO;
std::vector<TOTO> _v;
_v.push_back((TOTO){10, 'a'});
_v[0].a = 101;