🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3042

definition of strNcpy

#3042
From: Pete Lipson
Date: Fri, 18 Dec 1992 01:52
18 lines
1052 bytes
i was just badly bitten by my interpretation of how strncpy works.
  The MAN page for it IMPLIES that it works this way; is the standard this
ambiguous too?

  if you say:   strncpy(dst,"abcdef",4)

 does the standard really say you get five characters appended to the
dst (the chars 'a' 'b' 'c' 'd' AND the '\0') ???
  the man-page says it moves AT MOST the count (4 in this case) characters
but it ALSO says it returns a pointer to a NULL-TERMINATED result.

  I would have assumed in that case that you would have to move at most
3 non-null characters!
-- 
  /V\
-/@-*\- Peter Lipson <-- lipson@agames.com   or   netcom!dms!lipson
 \_o_/  Milpitas, CA <-- Atari Games
   U
Technical Details
Message-ID: <1992Dec18.015228.6094@dms.agames.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!dms!lipson

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!spool.mu.edu!umn.edu!csus.edu!netcom.com!netcomsv!dms!lipson
From: lipson@dms.agames.com (Pete Lipson)
Newsgroups: comp.std.c
Subject: definition of strNcpy
Message-ID: <1992Dec18.015228.6094@dms.agames.com>
Date: 18 Dec 92 01:52:28 GMT
Organization: Atari Games Corporation
Lines: 18
X-Newsreader: TIN [version 1.1 PL6]