#include <iostream>
#include <iterator>
int main()
{
int myInt;
std::istream_iterator<int> myIstreamIterator(std::cin);
myInt = *myIstreamIterator;
std::cout << myInt << " "; // 1
myIstreamIterator++;
myInt = *myIstreamIterator;
std::cout << myInt << " "; // 2
myIstreamIterator++;
myInt = *myIstreamIterator;
std::cout << myInt << " "; // 3
std::cout << std::endl;
return 0;
}
// Input : 1 2 3
// Output: 1 2 3
Reference: http://www.cplusplus.com/reference/iterator/istream_iterator/
Wednesday, December 27, 2017
C++98: std::istream_iterator
The istream_iterator template class wraps a stream and returns an input iterator. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment