Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!night From: night@pawl.rpi.edu (Trip Martin) Newsgroups: comp.lang.c Subject: Re: Very elementary question concerning indirection Message-ID: Date: 16 Feb 90 05:57:02 GMT References: <49.25DAD22B@csource.oz.au> Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 32 david@csource.oz.au (david nugent) writes: > > printf( "%c\n",*(strchr(string,40)) ); <---- line in question > > > > If the "line in question" is commented out, the program compiles with > > one warning on line 7 (This is in Vax Ultrex C, no warning is given in > > Turbo C). What is wrong with the "line in question". Also, what does this > > warning mean? >It means I _like_ that compiler! :-) >Hmm, one clever enough to understand printf() style format strings is rather >nice. It must know it's looking for a char there.. >I'm not too surprised TC passes it with no comment. printf() is defined to >have a variable number of arguments, and no type checking at all is in >effect. You're missing the problem here. The compiler is complaining about dereferencing an integer. Now you and I know that strchr() returns a pointer to a char, but in this case the compiler doesn't know that so it assumes that strchr() returns a pointer to a char, so it is correct in complaining about the dereference. The error message has nothing to do with the semantics of printf. -- Trip Martin night@pawl.rpi.edu