From owner-freebsd-questions@FreeBSD.ORG Mon Feb 18 23:20:58 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E01E16A417 for ; Mon, 18 Feb 2008 23:20:58 +0000 (UTC) (envelope-from marcus@marcuscom.com) Received: from creme-brulee.marcuscom.com (penna-pt.tunnel.tserv1.fmt.ipv6.he.net [IPv6:2001:470:1f00:ffff::1279]) by mx1.freebsd.org (Postfix) with ESMTP id 173F513C46B for ; Mon, 18 Feb 2008 23:20:58 +0000 (UTC) (envelope-from marcus@marcuscom.com) Received: from [IPv6:2001:470:1f00:2464::4] (shumai.marcuscom.com [IPv6:2001:470:1f00:2464::4]) by creme-brulee.marcuscom.com (8.14.2/8.14.2) with ESMTP id m1INKvTh010616; Mon, 18 Feb 2008 18:20:57 -0500 (EST) (envelope-from marcus@marcuscom.com) From: Joe Marcus Clarke To: Gary Kline In-Reply-To: <1203376747.32200.21.camel@shumai.marcuscom.com> References: <20080218230351.GA28000@thought.org> <1203376747.32200.21.camel@shumai.marcuscom.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-lXjXtbXt6hp/Mu7osSjH" Organization: MarcusCom, Inc. Date: Mon, 18 Feb 2008 18:20:55 -0500 Message-Id: <1203376855.32200.23.camel@shumai.marcuscom.com> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 FreeBSD GNOME Team Port X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,NO_RELAYS autolearn=ham version=3.2.4 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on creme-brulee.marcuscom.com Cc: FreeBSD Mailing List Subject: Re: is there an easier way? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Feb 2008 23:20:58 -0000 --=-lXjXtbXt6hp/Mu7osSjH Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2008-02-18 at 18:19 -0500, Joe Marcus Clarke wrote: > On Mon, 2008-02-18 at 15:03 -0800, Gary Kline wrote: > > To my fellow C nerds, > >=20 > > It's been a great manny years since I wrote this appended > > snippet. Now I can't remember why (of if ) I need all the > > strcpy() calls. Is there a simpler, more logical way of=20 > > printing a bunch of string by snipping off the left-most? > >=20 > > In short,, can anyone 'splain why strtok needs all this? >=20 > Here are two examples, one with dynamically allocated memory, and one > with static memory. You need the copy so that you allocate writable > space for strtok() to fill in the NUL bytes. I imagine there are even > better/easier ways, but both of these work okay. Posted to http://www.marcuscom.com/downloads/strtokeg.c as the attachment didn't make it. Joe --=20 PGP Key : http://www.marcuscom.com/pgp.asc --=-lXjXtbXt6hp/Mu7osSjH Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEABECAAYFAke6EtYACgkQb2iPiv4Uz4cmTwCglFtzFUTT0f+9ZsOpKrUsNoGX ep0An0K+yDBn0rmwWmAq35upoG0pkxWn =b8nv -----END PGP SIGNATURE----- --=-lXjXtbXt6hp/Mu7osSjH--