string z,s;
while (true)
{
cin>>z;
s+=z;
if(cin.peek()=='
')
break;
}
................................
OR/
.................................
string s;
getline(cin,s);
int main() {
int sum = 0;
cout << "enter number" << endl;
int i = 0;
while (true) {
cin >> i;
sum += i;
//cout << i << endl;
if (cin.peek() == '
') {
break;
}
}
cout << "result: " << sum << endl;
return 0;
}
#include <string>
#include <vector>
...
string rawInput;
vector<String> numbers;
while( getline( cin, rawInput, ' ' ) )
{
numbers.push_back(rawInput);
}