Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!news1.google.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: Wed, 17 Aug 2011 23:41:55 -0500 Message-ID: <4E4C9814.53B@mindspring.com> Date: Thu, 18 Aug 2011 00:41:56 -0400 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: selection-sort in C References: <4e4a4fc9$0$313$14726298@news.sunsite.dk> <871uwlk39e.fsf@bazspaz.fatphil.org> <4e4a563d$0$313$14726298@news.sunsite.dk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 34 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.217.90 X-Trace: sv3-klJVxRT8dJw8C6HONtM5wyhpEJfePPHWDsHGBB4txwDHaRO42jjspY1f8gnYr6PbeJDem3y2A4G/vmr!Na+MQM4qFuqA/YLcuxPXG4GfvCZDVodPgQh+T/fXYjTONMl041JkvZQxJZ34QqIw1JQenuXJKisw!AppPTKzq 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: 2174 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:9510 Jorgen Grahn wrote: > > On Tue, 2011-08-16, arnuld wrote: > >> On Tue, 16 Aug 2011 14:24:45 +0300, Phil Carmody wrote: > > > >>> arnuld writes: > >>> int findSmallest(char s[], const int idx_cur, const int len); > > > >> The consts on those parameters don't do much, > >> but aren't actually wrong. > > > > Just to show that function is not supposed to change its arguments. > > That makes sense in the /definition/ of the function, provided you > want them to be const just like you might want any local variable to > be const. > > It does not make sense in the /declaration/. The compiler will just > go "of course you can't change the argument, stupid -- C uses call by > value!" Regardless of how arnuld phrased things, the const qualifiers which are shown above, apply to the parameters. Also, if the parameters are const qualified in the definition of a function, then they should also be const qualified in any prototype of that function. -- pete