cs161AWinter2024/getline2.cpp

23 lines
437 B
C++

#include <iostream>
#include <sstream>
using namespace std;
/*
Okay so where things get wild is that you can use >> and getline in surprising ways
*/
int main(){
string str;
int num1;
int num2;
cout << "Enter a couple of numbers separated by spaces" << endl;
getline(cin,str);
istringstream iss(str);
iss >> num1;
iss >> num2;
cout << "Your numbers, added together, are: " << num1 + num2 << endl;
return 0;
}