Confusion over main function syntax

M

Mark Hobley

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?

Why is the second syntax sometimes used?

Do the differences effect the build in any way?

Are both variants legal and correct in ANSI C (89)?

Thanks in advance to anyone who can help.

Mark.
 
I

Ian Collins

Mark said:
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?
Yes.

Why is the second syntax sometimes used?
Probably personal preference.
Do the differences effect the build in any way?
No.

Are both variants legal and correct in ANSI C (89)?
Yes.
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top