c++ - How do I convert this array to a vector? -


const int num_digits = 7; int pin1[num_digits] = {2, 4, 1, 8, 7, 9, 0}; int pin2[num_digits] = {2, 4, 6, 8, 7, 9, 0}; int pin3[num_digits] = {1, 2, 3, 4, 5, 6, 7}; 

std::vector defines constructor takes in 2 inputiterators , default allocator with

template <class inputiterator>      vector (inputiterator first, inputiterator last,              const allocator_type& alloc = allocator_type()); 

so can create vector array so,

std::vector<int> vec(pin1, pin1 + num_digits); 

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

formula - R: how to pass in a reference to the variable in glm or lm? -