From owner-freebsd-questions@FreeBSD.ORG Tue Feb 19 00:47:02 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 41D7816A417 for ; Tue, 19 Feb 2008 00:47:02 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from mx-out-01.forthnet.gr (mx-out.forthnet.gr [193.92.150.104]) by mx1.freebsd.org (Postfix) with ESMTP id 973A713C45D for ; Tue, 19 Feb 2008 00:47:01 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from mx-av-04.forthnet.gr (mx-av.forthnet.gr [193.92.150.27]) by mx-out-01.forthnet.gr (8.13.8/8.13.8) with ESMTP id m1J0kx5G015573; Tue, 19 Feb 2008 02:46:59 +0200 Received: from MX-IN-05.forthnet.gr (mx-in-05.forthnet.gr [193.92.150.32]) by mx-av-04.forthnet.gr (8.14.1/8.14.1) with ESMTP id m1J0kx1i029149; Tue, 19 Feb 2008 02:46:59 +0200 Received: from kobe.laptop (adsl48-14.kln.forthnet.gr [77.49.175.14]) by MX-IN-05.forthnet.gr (8.14.2/8.14.2) with ESMTP id m1J0kucN024002; Tue, 19 Feb 2008 02:46:59 +0200 Authentication-Results: MX-IN-05.forthnet.gr smtp.mail=keramida@ceid.upatras.gr; spf=neutral Authentication-Results: MX-IN-05.forthnet.gr header.from=keramida@ceid.upatras.gr; sender-id=neutral Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m1J0ktKX005558; Tue, 19 Feb 2008 02:46:55 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m1J0kqv9005557; Tue, 19 Feb 2008 02:46:52 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 19 Feb 2008 02:46:52 +0200 From: Giorgos Keramidas To: Tim Daneliuk Message-ID: <20080219004652.GD5362@kobe.laptop> References: <20080218230351.GA28000@thought.org> <47BA1375.2010108@tundraware.com> <47BA14F8.4060109@tundraware.com> <47BA17B6.20906@tundraware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47BA17B6.20906@tundraware.com> Cc: Gary Kline , freebsd-questions@freebsd.org 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: Tue, 19 Feb 2008 00:47:02 -0000 On 2008-02-18 17:41, Tim Daneliuk wrote: > Tim Daneliuk wrote: >> Ooops ... wasn't paying attention. While the printed output is the >> same, doing it this way is destructive to the original s1 string - >> which may matter (or not)... > > So, to protect the original string, you do have to copy the original > string to a new buffer: ... or use strcspn() and strspn() which are non-destructive (see my other post in the same thread about an example). I tend to prefer avoiding strtok() if possible, precisely because of its destructive behavior.