Message-ID: From: Cameron Weeks Newsgroups: comp.os.msdos.djgpp Subject: Re: In getopt.c wht is place declared as const References: <3B99AB68 DOT 19D91FCB AT dtcs DOT de> Lines: 39 Organization: Personal Use MIME-Version: 1.0 X-Newsreader: Turnpike Integrated Version 5.01 U Date: Sun, 09 Sep 2001 12:13:00 GMT NNTP-Posting-Host: 62.31.159.34 X-Complaints-To: http://www.blueyonder.co.uk/abuse X-Trace: news1.cableinet.net 1000037580 62.31.159.34 (Sun, 09 Sep 2001 13:13:00 BST) NNTP-Posting-Date: Sun, 09 Sep 2001 13:13:00 BST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello, Thanks for the reply, I already had a basic understanding of static and associated storage class specifiers, and const and associated type qualifiers. Most of my problem was specific to getopt.c. Why in this specific code have they declared place as const. I fact this may lead back to a more general question, to completely quote the code it is declared as: #define EMSG "" static const char *place = EMSG; Now surely this is a slightly dangerous thing to do. If EMSG was anything but "" then you would be writing to memory pointed to by an un-initialised pointer, therefore risking a crash. Also the rest of the getopt.c code doesn't give the address of place to any external functions, so why bother using const ? Also your bit of code did print 10,000 times, but I got the idea, I think you ment: > void say_hello() > { static int i=0; > > for(;i<10;i++) > printf("Hello, world\n"); > } > > main() > { int n; > > for(n=0;n<1000;n++) > say_hello(); > > return 0; > } Thanks again. ------ Cam...