Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!samsung!cs.utexas.edu!sun-barr!newstop!texsun!texbell!nuchat!buster!rli From: rli@buster.irby.com (Buster Irby) Newsgroups: comp.lang.c Subject: Re: strncpy Keywords: strncpy null termination Message-ID: <621@buster.irby.com> Date: 21 Dec 89 22:07:57 GMT References: <11509@csli.Stanford.EDU> <8313@stiatl.UUCP> Organization: Buster Irby, Stafford, Tx Lines: 26 cns@stiatl.UUCP (Chris Straut) writes: >I agree that strncpy should null terminate the resulting string. The >definition of a string in the C language is a null terminated char array. >And the function called (str)ncpy indicates a string operation, which by >default should create a null terminated string. To overcome this 'feature' >we wrote our own strncpy function, which is benefical to the unsuspecting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >programmer (or novice), and the result is a null terminated string. CAUTION: There is a lot of existing software in the world that would break if the operation of strncpy or any other standard library function were suddenly changed. You are asking for trouble any time you change the operation of a standard library function such as strncpy, and I would strongly suggest that you not do it. First of all, what happens when you take a piece of software that was not developed inhouse and compile it using your new strncpy function? Or what happens when you hire a senior level C programmer who is used to the way strncpy is documented to work? You are asking for trouble, and believe me, it can cost a lot of time and money to track down bugs which you introduce into the code like this. If you must create your own specialized version of any standard library function, you should call it by your own specialized name, not by its standard name. -- Buster Irby buster!rli