From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 30 18:03:35 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 0A2231065672 for ; Tue, 30 Jun 2009 18:03:35 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) Received: from zivm-out1.uni-muenster.de (ZIVM-OUT1.UNI-MUENSTER.DE [128.176.192.8]) by mx1.freebsd.org (Postfix) with ESMTP id 933268FC26 for ; Tue, 30 Jun 2009 18:03:34 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) X-IronPort-AV: E=Sophos;i="4.42,317,1243807200"; d="scan'208";a="275910304" Received: from zivmaildisp2.uni-muenster.de (HELO ZIVMAILUSER05.UNI-MUENSTER.DE) ([128.176.188.143]) by zivm-relay1.uni-muenster.de with ESMTP; 30 Jun 2009 20:03:21 +0200 Received: by ZIVMAILUSER05.UNI-MUENSTER.DE (Postfix, from userid 149459) id 47CE11B07E4; Tue, 30 Jun 2009 20:03:21 +0200 (CEST) Date: Tue, 30 Jun 2009 20:03:21 +0200 (CEST) From: Alexander Best Sender: Organization: Westfaelische Wilhelms-Universitaet Muenster To: Igor Mozolevsky Message-ID: In-Reply-To: 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 18:03:35 -0000 should be stdout. struct Header *hdr = rom; int new_fd = open("/dev/stdout", O_RDWR); printf("SIZE: %d\n",sizeof(*hdr)); write(new_fd, hdr, sizeof(*hdr)); close(new_fd); Igor Mozolevsky schrieb am 2009-06-30: > 2009/6/30 Alexander Best : > > that works, but i really want to have a pretty output to stdout. i > > guess i > > have to stick with printf and use `for (i=0; i < sizeof(XXX); i++)` > > for each > > array in the struct. just thought i could avoid it. > > btw. `./my-program | hexdump` works, but if i do `./my-program > > > output` > > output is being created, but is empty. is this normal? > Depends if you output to stdout or stderr --- `>' redirects stdout. > Cheers, > -- > Igor