0

How can you specify the characters that end the reading of a token with cin?

Defaults to / t, / n, '' ...
But I want to specify some specifics in a similar way to what the std::skipws and std::noskipws or std::ws functions do that allow you to specify whether or not the spaces are ignored, I would like to know if there is something more general for allow read up to some specific character, reads until it finds a string that matches the data type of the variable in which it is to be stored with the >> operator, in order to read and cut the token up to ' '

So that when entering the string A,B,C,D E,F G H,I, J

Each letter is a different string something similar to specifying with scanf ("% s,"...) to say that it expects a string followed by a comma that cuts the string but using cin.

Could someone help me?

Pd: It occurs to me to read the line and to replace ',' by ' ' in such a way that with stringstream I can do the extraction that I want, but this represents crossing the string twice and I look for something clean and efficient that provides the language or it is possible make it simple without much code.

gsamaras
  • 71,951
  • 46
  • 188
  • 305
  • Possible duplicate of [changing the delimiter for cin (c++)](https://stackoverflow.com/questions/7302996/changing-the-delimiter-for-cin-c) – Blastfurnace Jun 19 '17 at 00:50

1 Answers1

0

No you cannot do that. Parse the input and depending on the input, implement your logic with if statements for example.

gsamaras
  • 71,951
  • 46
  • 188
  • 305