0
#include<iostream>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
}

When I compile it, every integer is asked like there is endl between them. How can I write that so the program asks for a, b and c in one line and space between?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Pulpit
  • 85
  • 8
  • 2
    did you try it? – OznOg Nov 10 '19 at 17:31
  • 5
    your code can handle this, try input 3 space-separated integer yourself. – KagurazakaKotori Nov 10 '19 at 17:32
  • What you are asking for is exactly how `operator>>` already works. It reads whitespace-delimited values, and spaces and line breaks are both treated as whitespace. Otherwise, you can use `std::getline()` to read an entire line of input as a single `std::string`, and then use `std::istringstream` to read values from that string – Remy Lebeau Nov 10 '19 at 17:56

0 Answers0