!!<====== Existence of a variable - Debunk a myth ======>!!

A

August Karlstrom

Zero said:
For example,
Kim King says in his book "C programming - A modern approach":

'A statement is a command to be executed when the programs run'.
So nothing wrong with my statement: printf is a command.

Maybe it is more accurate to say that a command invocation is a
statement. Anyway the standard C terminology is:

printf function (identifier)
printf("abc") expression
printf("abc"); statement


August
 
D

David Thompson

(Terminology: a value can be "passed" to a function. I think you mean
until a value is assigned to it.)

What books say this? An auto variable exists from the point of its
declaration until the end of its scope.
Nit: the _scope_ of an auto declaration is from (specified points
within) the declaration to the end of the block containing it, or in
C99 for(decl;...) to the end of the for-stmt.

Except for C99 VLAs, its _lifetime_ is from _entry_ of the containing
block (or for?) -- which can be after the decl, or in C99 before --
until _exit_ from that block -- which can be before its end.

In particular, extremely silly things like this do work 'right':
int main (void)
{
/* !!! LEGAL BUT GROSSLY ATROCIOUS CODE !!! */
goto bar;
{
int x, *y;
foo: printf ("%d\n", *y); return 0;
bar: y = &x; x = 42; goto foo;
}
/* DON'T DO THAT! GIVE A HOOT! DON'T POLLUTE! */
}

<snip rest>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top