Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | blp@cs.stanford.edu (Ben Pfaff) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: fprintf internally supports print character array in hex? |
| Date | 2011-09-23 12:50 -0700 |
| Message-ID | <87pqir3unf.fsf@blp.benpfaff.org> (permalink) |
| References | <j5ifbi$irm$1@dont-email.me> <0.60d7480fd9f3d3b77b0d.20110923184756BST.87sjnnw3oz.fsf@bsb.me.uk> <j5inkl$dr3$1@dont-email.me> |
mathog <dmathog@gmail.com> writes:
> Ben Bacarisse wrote:
>
>> No. The only "multiple" formats are for strings formatted as
>> characters.
>
> Well, that was sort of my point. By (slightly odd) analogy, it is
> as if the language implements
>
> od -c file
>
> (via the %s format) but not
>
> od -x file
>
> The only difference is how each char is formatted. Ah, wait, I see
> why they didn't do it, the zero character is a string delimiter, so
> that sort of format string would not be very useful for printing
> general
> hex data. But printing strings which are not null terminated is also
> a problem.
No it's not. Use "%.*s".
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
fprintf internally supports print character array in hex? mathog <dmathog@gmail.com> - 2011-09-23 10:23 -0700
Re: fprintf internally supports print character array in hex? blp@cs.stanford.edu (Ben Pfaff) - 2011-09-23 10:32 -0700
Re: fprintf internally supports print character array in hex? mathog <dmathog@gmail.com> - 2011-09-23 10:38 -0700
Re: fprintf internally supports print character array in hex? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-23 18:47 +0100
Re: fprintf internally supports print character array in hex? mathog <dmathog@gmail.com> - 2011-09-23 12:45 -0700
Re: fprintf internally supports print character array in hex? blp@cs.stanford.edu (Ben Pfaff) - 2011-09-23 12:50 -0700
Re: fprintf internally supports print character array in hex? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-09-23 21:34 +0100
Re: fprintf internally supports print character array in hex? mathog <dmathog@gmail.com> - 2011-09-23 16:12 -0700
Re: fprintf internally supports print character array in hex? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-09-30 01:06 -0700
Re: fprintf internally supports print character array in hex? "BartC" <bc@freeuk.com> - 2011-09-30 12:36 +0100
Re: fprintf internally supports print character array in hex? David Thompson <dave.thompson2@verizon.net> - 2011-10-03 01:11 -0400
Re: fprintf internally supports print character array in hex? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-29 21:41 +0000
Re: fprintf internally supports print character array in hex? Gene <gene.ressler@gmail.com> - 2011-10-03 02:26 -0700
csiph-web