I\'m trying to ask the user to enter numbers that are put into a vector, then using a function call to count the numbers, why is this not working? I am only able to count t
One-liner to read a fixed amount of numbers into a vector (C++11):
#include #include #include #include #include int main() { const std::size_t LIMIT{5}; std::vector collection; std::generate_n(std::back_inserter(collection), LIMIT, []() { return *(std::istream_iterator(std::cin)); } ); return 0; }