Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!uw-beaver!teknowledge-vaxc!sri-unix!quintus!jbeard From: jbeard@quintus.uucp (Jeff Beard) Newsgroups: comp.lang.c Subject: Re: `static' Message-ID: <255@quintus.UUCP> Date: 5 Aug 88 23:09:12 GMT References: <644@m10ux.UUCP> <503@draken.nada.kth.se> <12840@mimsy.UUCP> Sender: news@quintus.UUCP Reply-To: jbeard@quintus.UUCP (Jeff Beard) Organization: Quintus Computer Systems, Inc: Mountain View, Ca Lines: 32 % Finally, returning to string constants: these are unnamed objects, and % hence the scoping rules for names are irrelevant. There simply is no % name to be scoped. The objects do, however, have static storage duration: % they exist at all times. Thus, once you have a pointer to a string % constant, you can follow that pointer at any time. The string shall % not vanish from underfoot, unless the whole program vanishes with it. 1) program scoped static char * foo may be altered anywhere by any procedure and thus the original string reference will be lost to all, even though the string it self persists. static char * header; header = " Center Heading For Report "; .... printf(header); /* performs as expected */ .... header = " Center Footing For Report "; .... printf(header); /* yields a FOOTING as a Header ... OhMy! */ 2) which brings up another storage class often forgotten altogeter: READONLY as in a format string given for printf() printf("text %c not of type %s\n" args, ..); xstr() collects said strings to reduce storage costs at possible expense of memory thrashing to get at a non-local page.