TIP: Click on subject to list as thread! ANSI
echo: locsysop
to: Paul Edwards
from: Bob Lawrence
date: 1996-11-12 10:54:52
subject: Special Requests

BL> Does a static array persist after the function has been called?

 PE> Yes.

 BL> How strange. You call a function, close the function, and the
 BL> data stays... sort of like global data on demand. How do you
 BL> get rid of it?

 PE> You can't.

  Aaarrgh! Run for your life! The STATIC CHAR!

 BL> Why not just make it global?

 PE> Well, once you start using global variables you have to name
 PE> them so that no other module uses that same name. Declaring
 PE> them static local means that you can name them whatever you
 PE> want.

  Ahh! Now I understand! That's a real trap for young players... a
global with the same name local. I do it all the time. Whatta good
idea. 

... [later]

  I just used one. I wanted to convert the CRC to hex so I created a
little static array to hold the hex characters and it works like a
charm. I like it! Thank you. I understand that now.

  I'm still not convinced about your pointers to pointers, though. In
your CRC thingie you go main(char **argv) and I can't see how that's
any better than main(char *argv[]). You still pass a pointer, and it's
too easy to forget that argv is really an array.

  My approach is to set up some real memory somewhere - do that with
malice aforethought, first - and then access it with pointers. The
idea of pointers to pointers is very dangerous, to me. It would be too
easy to point to a pointer and then destroy the memory that *that* one
is pointing to.

Regards,
Bob
 
___ Blue Wave/QWK v2.12
@EOT:

---
* Origin: Precision Nonsense, Sydney (3:711/934.12)
SEEN-BY: 711/934 712/610
@PATH: 711/934

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™.