TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Darin McBride
from: Herman Schonfeld
date: 1998-08-13 15:01:44
subject: global pointers

DM>Yes, there's a significant difference between them.  In fact, if you
DM>had:

DM>int main()
DM>{
DM>  static char* text;

DM>  // rest of code
DM>}

DM>This, too, would fail to run.  Your 'working' version only works on DOS,
DM>however, and even then, should fail in protected-mode (32-bit, usually)
DM>DOS. That's because a variable allocated on the stack is uninitialized
DM>(contains garbage), and the standard says that variables not otherwise
DM>explicitly initialized that are global in duration (i.e., last
DM>throughout the program, such as global variables and static variables)
DM>are initialized to zero, or the equivalent thereof (i.e., NULL for
DM>pointers).

That's what I had assumed. Except after consulting the DJGPP docs for
examples, they use unallocated variables in their examples - I should've
realised it was DJGPP fault, again!

Note that in pmode it does work (the local pointer version).

... Help! I can't find the "ANY" key.
--- Ezycom V1.48g0 01fd016b
* Origin: Fox's Lair BBS Bris Aus +61-7-38036821 V34 +Node 1 (3:640/238)
SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728 810
SEEN-BY: 639/252 670/213 218
@PATH: 640/238 201 270/101 396/1 633/260 635/506 728 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™.