Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!emory!stiatl!cns From: cns@stiatl.UUCP (Chris Straut) Newsgroups: comp.lang.c Subject: Re: strncpy Keywords: strncpy null termination Message-ID: <8313@stiatl.UUCP> Date: 21 Dec 89 13:29:46 GMT References: <11509@csli.Stanford.EDU> Reply-To: cns@stiatl.UUCP (Chris Straut) Organization: Sales Technologies Inc., "The Little Shop of Horrors..." Lines: 18 In article <11509@csli.Stanford.EDU> poser@csli.Stanford.EDU (Bill Poser) writes: > Why is it that strncpy(3) does not null terminate >the string if the length of the source string is greater than >or equal to the length of the target buffer? [ other stuff deleted ] 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. -- Christopher Straut | Go Jackets!!!!! gatech!stiatl!cns Sales Technologies, Inc | 3399 Peachtree Rd, NE | Atlanta, GA (404) 841-4000 |