Mark Hobley wrote:
Quote:
A program typically has a main function defined as follows:
>
int main (int argc, char *argv[]) {
/* blah blah */
}
>
I have noticed that some programs use the syntax:
>
int main (int argc, char **argv) {
/* blah blah */
}
>
Is there a difference between the two methods above, or are they
completely interchangeable? Could I change the startup line
from the second example to the startup line in the first without any
effects on the programs behaviour?
This is Question 6.4 in the comp.lang.c Frequently
Asked Questions (FAQ) list, <http://www.c-faq.com/>.
Quote:
Why is the second syntax sometimes used?
Because the first syntax sometimes isn't? They mean
the same thing, so it's just a matter of the programmer's
own preference as to which is more expressive. You can
write `int a; int b; int c;' or `int a, b, c;'. "You can
call me Ray, or you can call me Jay," but either way it
means "Johnson."
Quote:
Do the differences effect the build in any way?
(You mean "affect," not "effect.") Probably not, since
the two mean the same thing. Still, compilers are always at
liberty to emit non-required diagnostic messages, and it's
conceivable that some compiler somewhere might squawk about
one form but not about the other.
Quote:
Are both variants legal and correct in ANSI C (89)?
Yes, and in all subsequent Standards, too.
--
Eric Sosman
esosman@ieee-dot-org.invalid