You want to type "13" and set a=1 and b=3?
no no,
if someone types 1 and after the space an other number it takes the number after the space as the next input and i want to prevent that.
Add #include <limits>
with your other include(s).
After std::cin >> a;
add:
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
That will extract and discard any remaining characters in std::cin's buffer.
Oh, so
1 3
2
should result in a=1 and b=2.