Path: utzoo!censor!geac!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!julius.cs.uiuc.edu!usc!jarthur!nntp-server.caltech.edu!bruce From: bruce@seismo.gps.caltech.edu (Bruce Worden) Newsgroups: comp.lang.c Subject: char *'s and const char *'s Message-ID: <1991Jan11.182945.5437@nntp-server.caltech.edu> Date: 11 Jan 91 18:29:45 GMT Sender: bruce@seismo.gps.caltech.edu (Bruce Worden) Organization: California Institute of Technology, Pasadena Lines: 26 Nntp-Posting-Host: sis.gps.caltech.edu 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 * pointer from const * A possible solution is: char str[] = "myfile"; . . . a = foo(str); but this distances the file name from the function call (a minor inconvenience). The question: What is the method preferred/recommended by professionals and other experienced individuals? -------------------------------------------------------------------------- C. Bruce Worden bruce@seismo.gps.caltech.edu 252-21 Seismological Laboratory, Caltech, Pasadena, CA 91125