Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!cfctech!teemc!ka3ovk!ki4pv!tanner From: tanner@ki4pv.UUCP (Dr. T. Andrews) Newsgroups: comp.lang.c Subject: Re: strncpy Message-ID: <0000006@ki4pv.UUCP> Date: 27 Dec 89 13:42:45 GMT References: <11527@csli.Stanford.EDU> Organization: CompuData Inc., DeLand Lines: 30 In <11527@csli.Stanford.EDU>, From: poser@csli.Stanford.EDU (Bill Poser) writes... ) Only a genius like Dr. Tanner would think of not overflowing ) the buffer. At the very least, we may assume that people at Stanford have not considered allocating a buffer of sufficent size for their purposes. ) The "waste" of the terminating null is REQUIRED so long as one ) conforms to the usual, null-terminated representation of strings ) in C. If one had strings which fit neatly into that mold, one would surely use strcpy(), not strncpy(). Except, of course, at Stanford, where strncpy() and on buffers of known size are an important subject of research; we expect Mr. Poser's paper on the same shortly. ) All other representations of arbitrary length strings require ) similar overhead, e.g. a character count in the descriptor. I beg to differ. By defining storage fields of a certain size, and using strncpy() to manipulate them, "strings" of that size may be handled without character counts in the descriptors. That a function strncpy() has been provided for such a cases is nice, but simply a convenience. That they don't teach people about character arrays of known size at Stanford is purely a local teaching decision and therefore not a suitable subject for outside debate. Of course, it may not be all of Stanford. It may just be that Mr. Poser's brain is broken. ...!{bikini.cis.ufl.edu allegra attctc bpa uunet!cdin-1}!ki4pv!tanner