Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 09 Feb 2012 18:22:15 -0600 Message-ID: <4F346336.E97@mindspring.com> Date: Thu, 09 Feb 2012 19:22:14 -0500 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: Replacing NULLS with space (C strings) References: Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 29 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.220.70 X-Trace: sv3-IKWFEbsqO8H/62ShsFP3NEwZPjpdJkEQYCGlFvxK4NNtvhukKGxZ5WLFOUyeTeNDRnn0N3KuHTQbg0j!Ve8TLTVK4/yASNM0UFdmvuNXXsSro0hKFjdNb4MQ23q+MXIfT6lyI88QTPvmUQ0S737ajITFhb6c!GwHZfkzH X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1920 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:17015 John Gordon wrote: > > In peter writes: > > > In fact, I want to remove all NULLS and EOFs (0x1a) > > from a string then replace them all with spaces. The way I do it > > now is by using a for() loop: > > > for(temp=0;temp<=strlen(buffer);temp++) > > { > > if(buffer[temp]== '\0' || buffer[temp]==0x1A) > > {buffer[temp]=' ';} > > } > > C strings are terminated by a NULL character. > Therefore, by definition, > you won't find any NULLs in the string itself. By definition, a string includes a null character. ISO/IEC 9899:201x Committee Draft — April 12, 2011 N1570 7. Library 7.1 Introduction 7.1.1 Definitions of terms 1 A string is a contiguous sequence of characters terminated by and including the first null character. -- pete