Path: 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
Summary:
Expires:
Sender:
Followup-To:
Keywords:

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