1

I have a c++ code to cin>> first a integer and then a string like below

int num;
string sentence;
cin>>num;
std::getline(std::cin, sentence);
cout << "Num is " << num<<endl;
cout << "Sen is " << sentence << endl;

I am supplying the input int two forms . See Case 1 and Case 2 below

**Case 1:** 
**Input:**
1
some sentence here

**Output:** 
Num is 1
Sen is 

**Case 2:**

**Input:**
1 some sentence here

**Output:** 
Num is 1
Sen is some sentence here

Can some one explain the above output. Also I want the second output for first input. How do I do that.

user27111987
  • 995
  • 2
  • 10
  • 26

0 Answers0