Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!uvaarpa!babbage!watt.acc.Virginia.EDU!pts From: pts@watt.acc.Virginia.EDU (Paul T. Shannon) Newsgroups: comp.lang.c Subject: strncpy question Message-ID: <630@babbage.acc.virginia.edu> Date: 10 May 89 15:39:35 GMT Sender: acc@babbage.acc.virginia.edu Reply-To: pts@watt.acc.Virginia.EDU (Paul T. Shannon) Distribution: na Organization: Academic Computing Center, University of Va. Lines: 16 I have a question on the strncpy library function. (The same question applies to strcpy as well.) This program fragment seems to be the recommended usage: char *original, *copy; /* assume that original points to a string */ int stringLength; stringLength = strlen (original); copy = malloc (stringLength + 1); /* allow room for terminating null */ copy = strncpy (copy, original, stringLength); Why is this function written so that the pointer to the destination string is both 1. passed as an argument to the function, and 2. returned by the function? Paul Shannon