Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How can you edit the std::cin delim char?

Reply
Thread Tools

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

 
 
Alex Snast
Guest
Posts: n/a
 
      06-25-2008
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.
 
Reply With Quote
 
 
 
 
Jerry Coffin
Guest
Posts: n/a
 
      06-25-2008
In article <91ee4eb9-768d-4db2-99b2-a9132f6646a8
@z66g2000hsc.googlegroups.com>, http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> 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.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
 
 
 
Alex Snast
Guest
Posts: n/a
 
      06-25-2008


Jerry Coffin כתב:
> In article <91ee4eb9-768d-4db2-99b2-a9132f6646a8
> @z66g2000hsc.googlegroups.com>, (E-Mail Removed) says...
> > 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.
>
> --
> Later,
> Jerry.
>
> The universe is a figment of its own imagination


How do i do it. can you show me a code example please.
 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      06-25-2008
In article <851d9b3b-1783-4585-8368-6a14f2c1fa87
@a70g2000hsh.googlegroups.com>, (E-Mail Removed) says...

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


http://groups.google.com/group/alt.comp.lang.learn.c-
c++/browse_frm/thread/9ee70fc9a0fffa1c/c9daefcb5147bb19#c9daefcb5147bb19

Has one example.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to read tab delim file into 2D Array yogi_bear_79 C++ 9 03-30-2008 05:53 PM
Gen. Row objects from tab-delim text lines danbernier+ruby@gmail.com Ruby 0 07-07-2006 07:55 PM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
get(char*, num, delim) question Francis Bell C++ 12 05-24-2004 04:14 AM



Advertisments