Mail Archives: djgpp/2001/09/09/08:17:45
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...
- Raw text -