Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site a.sei.cmu.edu Path: utzoo!linus!philabs!cmcl2!seismo!rochester!pt.cs.cmu.edu!a.sei.cmu.edu!dlc From: dlc@a.sei.cmu.edu (Daryl Clevenger) Newsgroups: net.lang.c Subject: Re: Need strnlen(). Message-ID: <207@a.sei.cmu.edu> Date: Wed, 13-Nov-85 15:20:39 EST Article-I.D.: a.207 Posted: Wed Nov 13 15:20:39 1985 Date-Received: Fri, 15-Nov-85 20:25:13 EST Organization: Carnegie-Mellon University, CS/RI Lines: 10 One should never allow a character array to not have a null terminating byte. Doing things like this should be automatic. Besides, usually when the program dumps core, one usually can find the problem readily. Also, if I am not mistaken, having character arrays that do not have terminating null bytes will cause problems with many other funtions e.g printf(). printf() (or maybe _doprint() I'm not sure which) will keep printing characters until they hit that null byte, but they probably won't find it where it should be. Unless I'm wrong, making sure strings are null terminated should be as automatic as making sure that you aren't trying to use NULL pointers or that malloc() returns a valid pointer.