From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 30 19:27:50 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 AE4771065672 for ; Tue, 30 Jun 2009 19:27:50 +0000 (UTC) (envelope-from stephen@missouri.edu) Received: from cauchy.math.missouri.edu (cauchy.math.missouri.edu [128.206.184.213]) by mx1.freebsd.org (Postfix) with ESMTP id 7A3308FC12 for ; Tue, 30 Jun 2009 19:27:50 +0000 (UTC) (envelope-from stephen@missouri.edu) Received: from [128.206.184.213] (cauchy.math.missouri.edu [128.206.184.213]) by cauchy.math.missouri.edu (8.14.3/8.14.3) with ESMTP id n5UJHYeJ047529; Tue, 30 Jun 2009 14:17:34 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <4A4A64CE.1030906@missouri.edu> Date: Tue, 30 Jun 2009 14:17:34 -0500 From: Stephen Montgomery-Smith User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.21) Gecko/20090611 SeaMonkey/1.1.16 MIME-Version: 1.0 To: Alexander Best References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: rick-freebsd2008@kiwi-computer.com, 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 19:27:50 -0000 Alexander Best wrote: > thanks. now the output gets redirected using >. i'm quite new to programming > under unix. sorry for the inconvenience. > > so i guess there is no really easy way to output an inhomogeneous struct to > stdout without using a loop to output each array contained in the struct. > > cheers. I think you are asking for a print command, that when given a structure, can look at the data type of each element of the structure, and produces the appropriate print command for each data type. I think what you are asking for is antithetical to the philosophy of C - for example, the printf command demands that you tell the printf command what are the data types of the data you give to it. So I think that the kind of long winded print command you are advocating is the correct way to do it. Stephen