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
  • 11,148
  • 4
  • 27
  • 40

0 Answers0