🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #305

Interpretation question: Pointers to explicitly zero-length strings

#305
From: Jerry Leichter
Date: Fri, 07 Jul 1989 19:04
14 lines
1188 bytes
A number of the ANSI C library functions accept a string argument, together
with a maximum length.  Obvious examples include strncpy and printf (%s can
accept a maximum length).  If the maximum length given is zero, must the
pointer passed be valid?  In particular, may it be 0, as in:

	strncpy(s,NULL,0);

This may sound like a silly question if you look only at an isolated example
with constants in it, but it arises naturally when dealing with strings
represented using a (length,pointer) structure.  When the length is 0, it
makes little difference where the pointer points, but it is often simplest -
in initialization, for example - to let it just be 0.

							-- Jerry
Technical Details
Message-ID: <65745@yale-celray.yale.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!yale!leichter

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!yale!leichter
From: leichter@CS.YALE.EDU (Jerry Leichter)
Newsgroups: comp.std.c
Subject: Interpretation question:  Pointers to explicitly zero-length strings
Message-ID: <65745@yale-celray.yale.UUCP>
Date: 7 Jul 89 19:04:53 GMT
Sender: root@yale.UUCP
Organization: Yale Computer Science Department, New Haven, Connecticut, USA
Lines: 14
X-from: leichter@CS.YALE.EDU (Jerry Leichter (LEICHTER-JERRY@CS.YALE.EDU))