Boost logo

Boost Users :

Subject: Re: [Boost-users] How to use filtering streams with cin?
From: Jayden Shui (jayden.shui_at_[hidden])
Date: 2011-11-16 09:27:51


Hi Larray,

I get it by setting a 0 buffer size. Thanks a lot!

Best regards,

Jayden

On Wed, Nov 16, 2011 at 6:39 AM, Larry Evans <cppljevans_at_[hidden]>wrote:

> On 11/15/11 22:26, Jayden Shui wrote:
> > Hello All,
> >
> > I have trouble in using filtering streams with cin in the following code:
> >
> > #include <boost/iostreams/filtering_stream.hpp>
> > #include <iostream>
> >
> > namespace io = boost::iostreams;
> >
> > int main()
> > {
> > io::filtering_istream in;
> > in.push(std::cin);
> >
> > int i;
> > in >> i;
> > std::cout << i << '\n';
> > in >> i;
> > std::cout << i << '\n';
> > }
> >
> > I have to input two integers and ctrl+z to terminate the input from
> > screen. How can I input 1 integer, output it, then input another one and
> > output it, which like the conventional std::cin?
> >
> Hi Jayden,
>
> It sounds like filtering_istream, in, is buffering its input.
> Is there some filtering_istream option for unbuffered input?
> If so, try that.
>
> HTH,
>
> -Larry
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net