Re: c question: *printf'ing arrays



thanks. but that simply dumps the contents of the struct to stdout. but since
most of the struct's contents aren't ascii the output isn't really of much
use.

cheers.

Tom Evans schrieb am 2009-06-30:
On Tue, 2009-06-30 at 18:12 +0200, Alexander Best wrote:
hi there,

i need to output the header of a file to stdout. the header looks
like this:

struct Header
{
u_int8_t rom_entry[4];
u_int8_t nintendo_logo[156];
u_char game_title[12];
u_char game_code[4];
u_char maker_code[2];
u_int8_t fixed_val;
u_int8_t unit_code;
u_int8_t device_type;
u_int8_t reserved_area1[7];
u_int8_t software_version;
u_int8_t complement_check;
u_int8_t reserved_area2;
u_int8_t ram_entry[4];
u_int8_t boot_mode;
u_int8_t slave_id;
u_int8_t unused_area[26];
u_int8_t joybus_entry[4];
};

if there a way to use printf or some other variant of *printf
without using
sizeof()-loops for all the arrays?

cheers.

None of your arrays are dynamically sized, so surely
write(fd, &hdr, sizeof(Header));
would do the trick?

Cheers

Tom
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: struct over tcp socket
    ... however doing it over the internet it ... When sending a struct directly this way, ... The best class of protocols are the ASCII based one. ... For strings, you'll get ...
    (comp.unix.programmer)
  • Re: struct over tcp socket
    ... however doing it over the internet it ... When sending a struct directly this way, ... The best class of protocols are the ASCII based one. ... For strings, you'll get ...
    (comp.unix.programmer)
  • Re: Perl XML::Simple and Data::Dumper - exists in Python?
    ... Miguel Manso wrote: ... > Can you point me out to Python solutions for: ... > It dumps any perl variable to the stdout in a "readable" way. ...
    (comp.lang.python)
  • Re: trouble exporting *.mat to ascii
    ... Attempt to write an unsupported data type to an ... ASCII file. ... struct using save -ascii. ...
    (comp.soft-sys.matlab)
  • RE: How to get Word docs content(text) ?
    ... You could also have a look at the filtdump.exe tool in the Platform SDK which effectively does exactly this and dumps the text to stdout... ... James ...
    (microsoft.public.sharepoint.portalserver.development)