-3

could you explain me when the reading of an int in C++ is terminated ? Is it terminated with withespace just as when we read into a string type object ?

Piero Borrelli
  • 1,151
  • 2
  • 11
  • 15

1 Answers1

0

If you have input line as space separated list like say 2 43 56, you need to read this as three integers as:

std::cin >> a >> b >> c;

where

int a, b, c;

Otherwise you need use cin.getline as in:

std::string name;
std::getline(std::cin, name);

and then parse, as required

Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69