Path: utzoo!utgpu!watserv1!watmath!att!rutgers!usc!snorkelwacker!mit-eddie!uw-beaver!sumax!polari!6sceng!blm From: blm@6sceng.UUCP (Brian Matthews) Newsgroups: comp.sys.mac.programmer Subject: Re: Think C 4.01 bugs Message-ID: <455@6sceng.UUCP> Date: 16 Jul 90 18:04:34 GMT References: <9510@accuvax.nwu.edu> <40562@think.Think.COM> <25571@cs.yale.edu> Organization: Six Sigma CASE, Inc. Lines: 19 In article <25571@cs.yale.edu> tarr-michael@CS.YALE.EDU (michael tarr) writes: |char s1[10]; |char s2[20] = "A long string"; |strncpy(s1, s2, 8); | |s1 will not have a '\0' appended to the end. So far as I can tell this |is not per the standard definition. Yes it is. s1 should only have a 0 appended if s2 is shorter than 8 characters. It's not, so no 0 should be appended. This is how strncpy has been defined since the beginning of time (1970 or so :-)). |Also sizeof returns an int, but malloc and calloc require size_t! This |is hidden on a none highlighted single line of text... Caused me great |pain to find this... If Think C 4.01 claims to be ANSI conformant, this is definitely a bug. -- Brian L. Matthews blm@6sceng.UUCP