User Tools

Site Tools


c_-_c_streams:istream_iterator

C - C++ Streams - istream_iterator

#include <iostream>
using std::cout;
using std::cin;
using std::endl;
 
#include <iterator>
 
int main()
{
  cout << "Enter two integers: ";
 
  std::istream_iterator< int > inputInt( cin );
 
  int number1 = *inputInt; 
  ++inputInt;              
  int number2 = *inputInt; 
 
  std::ostream_iterator< int > outputInt( cout );
 
  cout << "The sum is: ";
  *outputInt = number1 + number2;
  cout << endl;
 
  return 0;
}
c_-_c_streams/istream_iterator.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki