It depends on whether you want to do it in a line by line basis or as a full set. For the whole file into a vector of integers:
int main() { std::vector<int> v( std::istream_iterator<int>(std::cin), std::istream_iterator<int>() ); }
If you want to deal in a line per line basis:
int main() { std::string line; std::vector< std::vector<int> > all_integers; while ( getline( std::cin, line ) ) { std::istringstream is( line ); all_integers.push_back( std::vector<int>( std::istream_iterator<int>(is), std::istream_iterator<int>() ) ); } }
Related Posts:
- C++ – pointer being freed was not allocated error
- Why use conio.h?
- What is EOF in the C programming language?
- Why would we call cin.clear() and cin.ignore() after reading input?
- Reading in from System.in – Java
- Reading from .txt file into two dimensional array in c++
- Using cin to input a single letter into a char
- Multiple inputs on one line
- istream and ostream problem – C++
- How to use redirection in C for file input
- Frontend Category Checkbox
- Input with pattern not working
- Pause Console in C++ program
- Why the switch statement cannot be applied on strings?
- How do I print out the contents of a vector?
- Iterate through a C++ Vector using a ‘for’ loop
- ‘was not declared in this scope’ error
- Simple dictionary in C++
- Good input validation loop using cin – C++
- Are the C++ & and * operators inverses in all contexts?
- C++ for each, pulling from vector elements
- How do I erase an element from std::vector<> by index?
- What’s the C++ version of Java’s ArrayList
- Incomplete Type Is Not Allowed
- When to use extern in C++
- how to implement quick sort algorithm in C++
- (->) arrow operator and (.) dot operator , class pointer
- How to reverse an std::string? [duplicate]
- What is the C version of RMI
- Difference between ‘strcpy’ and ‘strcpy_s’?
- What is uintptr_t data type
- const int = int const?
- Undefined reference to vtable
- In C++, what is a virtual base class?
- “Multiple definition of” C++ compiler error
- wntdll.pdb not loaded – Can’t see the exception
- C++: How to round a double to an int?
- What is move semantics?
- Using “super” in C++
- unsigned int vs. size_t
- Press Enter to Continue
- How to trim a std::string?
- How to find if a given key exists in a C++ std::map
- Parsing a comma-delimited std::string
- Correct way of looping through C++ arrays
- C++ how to read a line with delimiter until the end of each line?
- Random number c++ in some range
- What’s the equivalent of new/delete of C++ in C?
- C++: std does not have member “string”
- Fatal error: ‘stdafx.h’ file not found
- How do I add the MinGW bin directory to my system path?
- What’s the syntax for declaring an array of function pointers without using a separate typedef?
- C++ cannot open source file
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Sorting Linked List C++ with pointers
- Get Unix timestamp with C++
- Class prototyping
- 8 queens puzzle with user input c++
- How to dynamically allocate an array of pointers in C++?
- “used without template parameters”
- C++ Error ‘nullptr was not declared in this scope’ in Eclipse IDE
- C++ Simple hangman game
- “The system cannot find the file specified” when running C++ program
- Remove First and Last Character C++
- C++ Convert string (or char*) to wstring (or wchar_t*)
- Program received signal SIGSEGV, Segmentation fault
- Integer to hex string in C++
- Comparison of C++ unit test frameworks
- Error: free(): invalid next size (fast):
- Fastest way to Convert String to Binary?
- Reading data from file into an array
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Trying to use int in getline
- What is the difference between an Abstract Data Type(ADT) and a Data Structure?
- What does the term “empty loop” refer to exactly in C and C++?
- c++ error c2015: too many characters in constant
- Splitting a C++ std::string using tokens, e.g. “;”
- How to print (using cout) a number in binary form?
- What is the job of autogen.sh when building a c++ package on Linux
- Using G++ to compile multiple .cpp and .h files
- LPCSTR, LPCTSTR and LPTSTR
- How to do std::string indexof in C++ that returns index of matching string?
- variable or field declared void
- Invalid conversion from ‘char’ to ‘const char *’
- How do I deal with “signed/unsigned mismatch” warnings (C4018)?
- How can I get a file’s size in C++?
- Why can’t I make a vector of references?
- Is there a way to simulate the C++ ‘friend’ concept in Java?
- What does “-Wall” in “g++ -Wall test.cpp -o test” do?
- What does ‘return *this’ mean in C++?
- C++ equivalent of StringBuffer/StringBuilder?
- heap corruption detected | C++
- Get all posts from custom post type and insert in select input as metabox
- WordPress widget / plugin….fields not appearing in my widget
- How to save data of an input field to an array
- Override admin submit_button() functionality
- Sizing textarea field in custom metabox
- Allow HTML in Settings API input field
- Notices when submitting custom post type from front-end
- How to add input search field with roudned corners?