TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bo Simonsen
from: Pascal Schmidt
date: 2004-01-28 11:01:26
subject: Re: [C] Question about external variable initialization

Hi Bo! :-)

 BS> Well the point was to make strdup, if it's not existing, I really 
 BS> doubt that strndup would exist.
The point is: better implement strndup(), and not using strlen and strcpy
to do that. Way safer.

 BS>> I get in a NULL terminated string:
 BS>> H e l l o   W o r l d  \0   <- text + x
 BS>> 0 1 2 3 4 5 6 7 8 9 10 11   <- x
 BS>> strlen will return 11. So there will be space for \0.
 PS>> No, strlen will return 10.
 BS> Yes that's why we need a extra one! :)
I wasn't disputing that.

Ciao
Pascal

--- Msged/LNX 6.1.1
* Origin: Linux kernel 2.4.24 on Red Hat 7.3 (1:153/401.2)
SEEN-BY: 633/267 270
@PATH: 153/401 307 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.