From: rminnich AT sarnoff DOT com (Ron G. Minnich) Subject: strlen on NULL, final test 13 May 1998 23:25:52 -0700 Message-ID: References: <6tksqweppfB AT mike DOT franken DOT de> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: gnu-win32 AT cygnus DOT com to finish this off once and for all, someone raised the question of a strlen that might test the argument to see if it's equal to 0, and then return 0. First, the empty string and the null string are different, and length of a null string has no meaning. Second, if you have null pointers, as others say, fix your code. But, even though it's a bad idea, who knows: someone might do it. bash$ cat test.c main() { (void) strlen((char *) 0); } bash$ cc test.c bash$ ./a.out Segmentation fault (core dumped) bash$ Again: linux, freebsd, sunos, solaris. So I have not yet seen the strlen that works with strlen((char *)0); ron Ron Minnich |Java: an operating-system-independent, rminnich AT sarnoff DOT com |architecture-independent programming language (609)-734-3120 |for Windows/95 and Windows/NT on the Pentium ftp://ftp.sarnoff.com/pub/mnfs/www/docs/cluster.html - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".