I don’t understand why/if I should
pick the c89 standard versus a newer
standard like c99 (which is the newest
I assume).
A couple of reasons:
1) gcc’s C99 support is not quite complete, whereas its C89 support is. That’s why C89 (with GNU extensions) is the default. So if you’re an absolute stickler for programming to a standard using gcc, pick C89.
2) Microsoft’s compiler doesn’t really support C99 at all. So if you want to write portable C code, C89 is a common standard.
Is is safe to say that iso will update
their standard for C but the original
ANSI standard for C will always be the
same?
No, ISO C99 was also ratified as an ANSI standard. The name “ansi” being attached to C89 only is an unfortunate historical accident. That said, C89 will always be C89, it’s just not the most recent ANSI C standard.
Is it correct to say if I write the
loop the first way then i should be
accessible to the entire function, but
if I write it the second way then i is
only accessible to the for loop
REGARDLESS of what standard I compile
with?
You can’t write it the second way in C89 (i.e. with -pedantic to adhere to the standard), so there is no “regardless of what standard”. The versions of C with GNU extensions aren’t standards, they’re “dialects” (at least that’s what the man page calls them). In C89 the second loop isn’t legal, in C99 the second one confines the scope of i to the loop. Obviously in both cases, the first loop gives i a wider scope.
In fact, gcc doesn’t like the second loop in C89 even with GNU extensions enabled.