-1

Relevant code is as follows:

string output;
char letter, number, symbol;

cout << "Input a letter, number, and a symbol separated by a space: ";
getline(cin, output);
istringstream(output) >> letter >> number >> symbol;

However, if I type in a multiple digit number, it only saves the first one, and then whatever is assigned to symbol is.. not correct.

What am I doing wrong? How can I make it so it only stops reading when it hits a blank space?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • You store the number as a `char`, which is a unique character, no multiple digits won't work. You can try to change it to `int`. And what do you mean by "symbol"? – Chelmy88 Sep 22 '19 at 19:57

1 Answers1

3

letter, number, and symbol are all defined as char type so you're only going to get one character into each variable. Try making number an int instead.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
jkb
  • 2,376
  • 1
  • 9
  • 12