From owner-freebsd-questions@FreeBSD.ORG Mon Feb 18 23:19:11 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 882E816A419 for ; Mon, 18 Feb 2008 23:19:11 +0000 (UTC) (envelope-from marcus@marcuscom.com) Received: from creme-brulee.marcuscom.com (marcuscom-pt.tunnel.tserv1.fmt.ipv6.he.net [IPv6:2001:470:1f00:ffff::1279]) by mx1.freebsd.org (Postfix) with ESMTP id 2B31513C458 for ; Mon, 18 Feb 2008 23:19:11 +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 m1INJA40010592; Mon, 18 Feb 2008 18:19:10 -0500 (EST) (envelope-from marcus@marcuscom.com) From: Joe Marcus Clarke To: Gary Kline In-Reply-To: <20080218230351.GA28000@thought.org> References: <20080218230351.GA28000@thought.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-LIi0OgAAiJXzGTs5nffo" Organization: MarcusCom, Inc. Date: Mon, 18 Feb 2008 18:19:07 -0500 Message-Id: <1203376747.32200.21.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 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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:19:11 -0000 --=-LIi0OgAAiJXzGTs5nffo Content-Type: multipart/mixed; boundary="=-uqBPJIhpwgUmcjToi5jn" --=-uqBPJIhpwgUmcjToi5jn Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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? 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. Joe --=20 PGP Key : http://www.marcuscom.com/pgp.asc --=-uqBPJIhpwgUmcjToi5jn-- --=-LIi0OgAAiJXzGTs5nffo 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) iEYEABECAAYFAke6EmcACgkQb2iPiv4Uz4cLhwCdFBIBWFZ3cQJQ4tPPXZvccC3N FT4AnjBH/DS6qXdi6uSK93LqUyt4rF8o =LwIz -----END PGP SIGNATURE----- --=-LIi0OgAAiJXzGTs5nffo--