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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -