in.get() is an analogue of getchar() - reads individual characters (char) from the stream. The method returns an int_type instead of char_type so that it can also return the end-of-file indicator (eof).
To copy numbers into a vector from a text file, you can use istream_iterator :
#include <algorithm> // copy #include <iostream> #include <iterator> #include <vector> int main() { std::istream_iterator<int> numbers(std::cin), eof; // копируем по одному числу из ввода в вывод // std::copy(numbers, eof, std::ostream_iterator<int>(std::cout, "\n")); // или в вектор можно сохранить для дальнейшей обработки std::vector<int> a(numbers, eof); std::copy(a.begin(), a.end(), std::ostream_iterator<int>(std::cout, "\n")); }
istream_iterator<int>(in) uses the in >> i analog inside. Read more: How to find a word?
istream_iterator<int>. - jfs