Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!edcastle!aipna!rjc From: rjc@uk.ac.ed.cstr (Richard Caley) Newsgroups: comp.lang.c Subject: Re: char *'s and const char *'s Message-ID: Date: 12 Jan 91 20:02:18 GMT References: <1991Jan11.182945.5437@nntp-server.caltech.edu> Sender: news@aipna.ed.ac.uk Organization: Center for Speech Technology Research Lines: 31 In-reply-to: bruce@seismo.gps.caltech.edu's message of 11 Jan 91 18:29:45 GMT In article <1991Jan11.182945.5437@nntp-server.caltech.edu> bruce@seismo.gps.caltech.edu (Bruce Worden) writes: Given: int foo(char *file); And knowing that foo() really only needs a const char *, it is often called as: a = foo("myfile"); but a kindly compiler will warn something like: junk.c:7: warning: argument passing of non-const * [...] The question: What is the method preferred/recommended by professionals and other experienced individuals? I don't know about the high muckerty muck profesional types, but my first move would be to shout at the person responsible for the decalration. Of course, you have to be quite sure that the function really does not do anything to the string. Just because it is obvious it should not, that does not mean it won't just for the hell of it. Quick quiz: which three letter workstation manufacturer's `sscanf' writes to its first argument... Answers on a letter bomb to... -- rjc@cstr.ed.ac.uk