From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 2 00:39: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 62C631065678; Thu, 2 Jul 2009 00:39:46 +0000 (UTC) (envelope-from unixmania@gmail.com) Received: from mail-fx0-f218.google.com (mail-fx0-f218.google.com [209.85.220.218]) by mx1.freebsd.org (Postfix) with ESMTP id BCDCC8FC16; Thu, 2 Jul 2009 00:39:45 +0000 (UTC) (envelope-from unixmania@gmail.com) Received: by fxm18 with SMTP id 18so1081568fxm.43 for ; Wed, 01 Jul 2009 17:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=7Hm8mrvQ6C1BVA1/7lVpNlobGW1V67EWxEHMyprkI1c=; b=NKFy7bYdwugKI2kRneGu/x18q675nJPeK9Ckye6TF7nnIrYi+g2u3hDg/cJ20UcV/V Gx1qcy5+60IEHhCAQJKDDuCd1tmrt784dC3V9VaOJGyD1ACSC6h5MEyAKi+qh9a3H02w zkkzSkZEHfYvP+/k3Lez0dk7TutR6P4OqDh+0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=MQhqxDbAYtE4WbrFnrZq6JDrPNYGDCAgPPVpUvsNL2/w1YxlGobBqteg8sNsyWCpbZ OMUEVjF4bsP1XOHwdbYs7oJ2uS4JQjE4LldrVsu0rGieuBKDBLAARRQN2qff54ooAWyn 74YoyRMO5r8OiP0xuQxUbAxBVEccszecj4Y0g= MIME-Version: 1.0 Received: by 10.239.170.68 with SMTP id r4mr885875hbe.12.1246495183767; Wed, 01 Jul 2009 17:39:43 -0700 (PDT) In-Reply-To: <20090630225457.GR84786@elvis.mu.org> References: <20090630210238.GA33849@keira.kiwi-computer.com> <20090630225457.GR84786@elvis.mu.org> Date: Wed, 1 Jul 2009 21:39:43 -0300 Message-ID: From: "Carlos A. M. dos Santos" To: Alfred Perlstein Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: rick-freebsd2008@kiwi-computer.com, freebsd-hackers@freebsd.org, Alexander Best 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: Thu, 02 Jul 2009 00:39:46 -0000 On Tue, Jun 30, 2009 at 7:54 PM, Alfred Perlstein wrote= : > Hey Alex, > > People frown on macros, but this could be a good one: > > #define SPRINT(f, fmt) \ > =A0 =A0 =A0 =A0do {\ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for (_i =3D 0; _i < sizeof(f)/sizeof(f[0])= ; i++) \ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf(fmt, f[i]); \ > =A0 =A0 =A0 =A0}while(0) > > :D > > This should allow you to point to any _array_ and print each > element of it using format "fmt". > > Example: > SPRINT(Header->game_title, "%c"); Yes, it works, but using a loop to print a character array one char at a time is terribly inefficient. --=20 My preferred quotation of Robert Louis Stevenson is "You cannot make an omelette without breaking eggs". Not because I like the omelettes, but because I like the sound of eggs being broken.