TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Darin McBride
from: Jasen Betts
date: 2004-04-19 07:07:16
subject: Squares

Hi Darin.

17-Apr-04 20:15:18, Darin McBride wrote to Jasen Betts


 DM> Good catch!

 JB>>   char *s=target-1;
 JB>>   while(*++s) {...};

 DM> Not supported by the standard ;-)

  is it's not legal to point outside the allocated memory
  even though that result is never used?

 DM> char* s = target;

 DM> if (*s != '\0')
 DM> {
 DM>   do {
 DM>     ...
 DM>   } while (*++s);
 DM> }

if pointers are iplemented in some other way than as some sort of integer
there's a possibility that subtracting 1 may give a state. that's not
corrected by adding 1

 DM> Unfortunately, I'm not sure that there is a more real example.  All I
 DM> know is that the standard does not guarantee what happens when you
 DM> point to memory that is not given to you by the compiler

hmm.

 DM> All that said, I'm not sure that the while loop version is better than
 DM> the for
 DM> loop version.  ;-

Me too. The for loop doesn't need an explicit check for an empty string.

 -=> Bye <=-

---
* Origin: Black Holes were created when God divided by zero! (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 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™.