🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5450

Re: Thoughts on `const' parameters

#5450
From: T. William Wells
Date: Thu, 01 Dec 1988 05:31
19 lines
1190 bytes
In article <957@vsi.COM> friedl@vsi.COM (Stephen J. Friedl) writes:
:      Let's say that I have a function like strchr(), which
: might be written as:
:
:       char *strchr(const char *string, int ch)
:       [function body omitted]
:
:      What prevents me from passing a const argument (say, a string
: in readonly memory), locating my desired character within the string,
: and then storing a NUL there?  Nothing in the declaration prevents
: this, and I've not done anything illegal like playing cast games.

Nothing at all prevents you from doing this, other than your skill as
a programmer.  It's one of the loopholes.  All that the const modifier
says here is that the string isn't modified in the function.

---
Bill
{uunet|novavax}!proxftl!twwells!bill
Technical Details
Message-ID: <230@twwells.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!rutgers!ukma!uflorida!novavax!proxftl!twwells!bill
References: <957@vsi.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!rutgers!ukma!uflorida!novavax!proxftl!twwells!bill
From: bill@twwells.uucp (T. William Wells)
Newsgroups: comp.std.c
Subject: Re: Thoughts on `const' parameters
Message-ID: <230@twwells.uucp>
Date: 1 Dec 88 05:31:41 GMT
References: <957@vsi.COM>
Reply-To: bill@twwells.UUCP (T. William Wells)
Distribution: comp
Organization: None, Ft. Lauderdale
Lines: 19