Subj : Re: Software Job Market Myths To : comp.programming,comp.software-eng From : CTips Date : Thu Aug 18 2005 10:14 pm Baxter wrote: > "CTips" wrote in message > news:11ga43l49me62d2@corp.supernews.com... > >>Chris Sonnack wrote: >> >>>CTips writes: >>> >>> >>> >>>>>>Hint: you forgot a #include ... >>>>> >>>>>NFI why `const' is "wrong" :-) >>>> >>>>This code might be running on a freestanding implementation, in >>>>which case the strcat/strcpy functions might be roll-your-owns, >>>>in which case both the str being reserved and the addition of >>>>const-ness are not correct. >>> >>> >>>*Maybe* on the use of the str without the #include, but I really >>>don't see why the const would be wrong in a RYO. >>> >> >>Because the strcat/strcpy didn't use const's? You'd get warnings/errors >>from the compiler. > > > > Nope. Compiler could care less if you supply a non-const for a const > parameter. > > For: > char *strcpy( char *strDestination, const char *strSource ); > > > strDestination MUST be non- const, and space reserved. strcpy WILL make > changes to strDestination. > > strSource can be const or non-const - the compiler does not care. "const > char *strSource" means that strcpy will not make any changes to strSource. > > > Ummm...we're talking about freestanding implementations [with a RYO string implementation] where the prototype for strcpy is: char * strcpy(char *dst, char *src); If you use: foo( const char * x) { .... strcpy(.., x); } you'll get warnings. .