From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 30 17:10:46 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 618D0106567A for ; Tue, 30 Jun 2009 17:10:46 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) Received: from zivm-out3.uni-muenster.de (ZIVM-OUT3.UNI-MUENSTER.DE [128.176.192.18]) by mx1.freebsd.org (Postfix) with ESMTP id EB12A8FC20 for ; Tue, 30 Jun 2009 17:10:45 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) X-IronPort-AV: E=Sophos;i="4.42,317,1243807200"; d="scan'208";a="7214605" Received: from zivmaildisp2.uni-muenster.de (HELO ZIVMAILUSER05.UNI-MUENSTER.DE) ([128.176.188.143]) by zivm-relay3.uni-muenster.de with ESMTP; 30 Jun 2009 19:10:44 +0200 Received: by ZIVMAILUSER05.UNI-MUENSTER.DE (Postfix, from userid 149459) id 51B3F1B07E4; Tue, 30 Jun 2009 19:10:44 +0200 (CEST) Date: Tue, 30 Jun 2009 19:10:44 +0200 (CEST) From: Alexander Best Sender: Organization: Westfaelische Wilhelms-Universitaet Muenster To: Tom Evans Message-ID: In-Reply-To: <1246380570.2437.219.camel@strangepork.london.mintel.ad> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@FreeBSD.org Subject: Re: c question: *printf'ing arrays X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2009 17:10:46 -0000 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