Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watdaisy.UUCP Path: utzoo!watmath!watdaisy!djsalomon From: djsalomon@watdaisy.UUCP (Daniel J. Salomon) Newsgroups: net.lang.c Subject: When not to use "strcpy". Message-ID: <7077@watdaisy.UUCP> Date: Sun, 17-Mar-85 19:24:29 EST Article-I.D.: watdaisy.7077 Posted: Sun Mar 17 19:24:29 1985 Date-Received: Mon, 18-Mar-85 01:37:33 EST References: <7042@watdaisy.UUCP> <7044@watdaisy.UUCP> <1040@mordor.UUCP> <741@sdcsvax.UUCP> Distribution: net Organization: U of Waterloo, Ontario Lines: 19 > Unfortunately, the string copy routines in the standard library are > neither safe nor convenient. strcpy is only usable if you KNOW that > overrunning is impossible. ... > ... My solution is to use my own string routines, which always take the > maximum length of the destination string as a parameter. > > _Greg Davidson (Virtual Infinity Systems, San Diego) To all those who have been complaining about the flood of postings relating to the string copy idiom, Greg Davidson's letter gives an example of the type application in which it is important to know the efficiencie of the string copy idiom versus other string copying methods. 1) When one is writing low level, portable string handling routines and strcpy is not quite what you wanted. 2) When one is doing some other type of string scanning not supplied in the standard library. The point that I wanted to make is that shorter source code does not necessarily generate less object code.