0

I want to use getline for reading a string after taking an integer input with cin. But I'm being troubled with an extra space. Here is my code:

string y;
int x;
cin >> x;
getline(cin, y);

Say, for input: "5 Hello World"
Output comes: "5" as the integer & " Hello World" as the string.

Azeem
  • 7,659
  • 4
  • 22
  • 36

0 Answers0