basic input output related query

Hi, i have to show output like this, while taking input in one turn like shown here. please provide me some suggestions,The code i have written works but it takes input in 2 times i want in 1 time.

(input)Enter one integer and one real number: 4711 3.14159265
(out put)The real is: 3.142
The integer is: 4711


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main ()
{
  string mystr;
  float real=0;
  int number=0;

  cout << "Enter real number: ";
  getline (cin,mystr);
  stringstream(mystr) >> real;
  cout << "Enter integer: ";
  getline (cin,mystr);
  stringstream(mystr) >> number;
 // cout << "Total price: " << price*quantity << endl;
 cout << "The real is " << real << "the Integer is " << number << endl;
  return 0;
}
Topic archived. No new replies allowed.