#include#include using namespace std; int main() { stringstream input("1234 5678"); int num1, num2; input >> num1; char nextChar = input.get(); if (nextChar == ' ') { // Push back the space so we can read the next number input.putback(' '); input >> num2; } cout << "Num1: " << num1 << endl; cout << "Num2: " << num2 << endl; return 0; }
Num1: 1234 Num2: 5678The cpp istream putback method is part of the C++ standard library, which is included with most C++ compilers by default. There is no external package or library needed to use this method.