Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #14320
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Using cout to print hex values; surely you can't be serious |
| Date | 2012-02-20 03:19 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <3872944.347.1329736775505.JavaMail.geo-discussion-forums@pbjr9> (permalink) |
| References | <08081227-b09b-454f-b23d-85ebb98207c0@n12g2000yqb.googlegroups.com> <jgtsi8$5mb$1@dont-email.me> <1b7b2943-4c64-4737-be4b-a20c495148ad@db5g2000vbb.googlegroups.com> <4f41306e$1$1383$4fafbaef@reader1.news.tin.it> |
在 2012年2月20日星期一UTC+8上午1时24分19秒,io_x写道:
> "gwowen" <gwowen@gmail.com> ha scritto nel messaggio
> news:1b7b2943-4c64-4737-be4b-a20c495148ad@db5g2000vbb.googlegroups.com...
> On Feb 8, 1:15 pm, Victor Bazarov <v.baza...@comcast.invalid> wrote:
> > On 2/8/2012 12:16 AM, Chris Stankevitz wrote:
> >
> > Use 'printf', it seems to suit *this particular task* better.
>
> But sometimes you want to mix streaming objects with a custom
> operator<< with printing hex values of bytes. Are you suggesting
> interleaving
Well, after my carefully investigations of << and >>
, I bielive it is not so trivail in C++ to control.
For example, I have to set up bufers for a
data compressed encoder and decoder of various comprssion methods with options for fast speed RW operations or smaller sizes in the heap or the swap
files in the hd.
How do I pass the option?
Unless I design a control foarmt for the stream
or use some external methods to pass the options
to the stream operators, I can't think of better ways
in C++ stream operator reloading.
I am wondering is there other way for the >> and <<
operator reloadings.
>
> std::cout << complex_object;
> printf("%x",byte);
>
> and hope that buffering makes that OK?
>
> #io_x
> #yes if cout and printf use the same stream and the same stream buffer
>
> Alternatively, you may want to serialise some bytes to a
> std::stringstream or serialise some bytes to a stream provided by a
> library user as a std::ostream& arguments, or to a file which has been
> opened as an std::fstream ... or ... or ...
>
> fprintf is fine, if you're writing to a C-style FILE*.
> It's useless for anything else, and there are *plenty* of anything-
> elses.
>
> The standard stream-formatting API is an bloody disaster area, so full
> of gotchas and weirdness as to be almost-unusable. Boost::Format is
> the solution.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using cout to print hex values; surely you can't be serious Chris Stankevitz <chrisstankevitz@gmail.com> - 2012-02-07 21:16 -0800
Re: Using cout to print hex values; surely you can't be serious gwowen <gwowen@gmail.com> - 2012-02-08 03:54 -0800
Re: Using cout to print hex values; surely you can't be serious Victor Bazarov <v.bazarov@comcast.invalid> - 2012-02-08 08:15 -0500
Re: Using cout to print hex values; surely you can't be serious gwowen <gwowen@gmail.com> - 2012-02-08 06:49 -0800
Re: Using cout to print hex values; surely you can't be serious "io_x" <a@b.c.invalid> - 2012-02-19 18:24 +0100
Re: Using cout to print hex values; surely you can't be serious 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-20 03:19 -0800
Re: Using cout to print hex values; surely you can't be serious 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-21 03:08 -0800
Re: Using cout to print hex values; surely you can't be serious Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-08 15:20 +0000
Re: Using cout to print hex values; surely you can't be serious Leigh Johnston <leigh@i42.co.uk> - 2012-02-08 14:20 +0000
Re: Using cout to print hex values; surely you can't be serious Paavo Helde <myfirstname@osa.pri.ee> - 2012-02-09 00:41 -0600
Re: Using cout to print hex values; surely you can't be serious Ian Collins <ian-news@hotmail.com> - 2012-02-09 20:22 +1300
Re: Using cout to print hex values; surely you can't be serious gwowen <gwowen@gmail.com> - 2012-02-09 00:16 -0800
Re: Using cout to print hex values; surely you can't be serious Ian Collins <ian-news@hotmail.com> - 2012-02-09 21:44 +1300
Re: Using cout to print hex values; surely you can't be serious Juha Nieminen <nospam@thanks.invalid> - 2012-02-09 10:36 +0000
Re: Using cout to print hex values; surely you can't be serious gwowen <gwowen@gmail.com> - 2012-02-09 03:56 -0800
Re: Using cout to print hex values; surely you can't be serious scott@slp53.sl.home (Scott Lurndal) - 2012-02-09 17:06 +0000
Re: Using cout to print hex values; surely you can't be serious Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-02-12 15:59 +0000
Re: Using cout to print hex values; surely you can't be serious scott@slp53.sl.home (Scott Lurndal) - 2012-02-09 17:04 +0000
csiph-web