How can you edit the std::cin delim char?

A

Alex Snast

hello guys

I need to modify the std::cin delim char from the default ' ' and '\n'
characters to ',' i know that i can edit the delim in the getline
command however i'd like to know if there's something build in with me
having to overload the std::cin operator

thanks, Alex Snast.
 
J

Jerry Coffin

hello guys

I need to modify the std::cin delim char from the default ' ' and '\n'
characters to ',' i know that i can edit the delim in the getline
command however i'd like to know if there's something build in with me
having to overload the std::cin operator

There are a couple of possibilities. The delimiters are defined by the
locale, so you can define a new locale with the delimiters of your
choice.

You can also create a filtering streambuf to transform the input into a
format that's easier to deal with (e.g. take the commas in the original
input and replace them with spaces so the rest of the code only sees the
spaces that the iostream expects to use as delimiters.
 
A

Alex Snast

Jerry Coffin כתב:
There are a couple of possibilities. The delimiters are defined by the
locale, so you can define a new locale with the delimiters of your
choice.

You can also create a filtering streambuf to transform the input into a
format that's easier to deal with (e.g. take the commas in the original
input and replace them with spaces so the rest of the code only sees the
spaces that the iostream expects to use as delimiters.

--
Later,
Jerry.

The universe is a figment of its own imagination

How do i do it. can you show me a code example please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top