Is there a difference?

M

Materialised

Hi,
I often see 2 different declairations of the main() function, and I am
unsure of the difference. They are
int main(int argc, char *argv[])
int main(int argc, char **argv[])

What is the difference?
And are they both complient with the ANSI standard?
 
J

Joona I Palaste

Materialised said:
Hi,
I often see 2 different declairations of the main() function, and I am
unsure of the difference. They are
int main(int argc, char *argv[])
int main(int argc, char **argv[])
What is the difference?
And are they both complient with the ANSI standard?

The difference between these is that they declare parameters of
different type.
In the first, the parameter argv is of type "pointer to pointer to
char", but in the second, it's of type "pointer to pointer to pointer
to char".
The first complies with the ANSI standard, the second does not.
You might as well be asking what is the difference between int *i and
int **i.
 
J

Jeff

Materialised said:
Hi,
I often see 2 different declairations of the main() function, and I am
unsure of the difference. They are
int int main(int argc, char *argv[])
int main(int argc, char **argv[])

What is the difference?
And are they both complient with the ANSI standard?

R U sure you don't mean, what is the difference between

int main(int argc, char *argv[])
and
int main(int argc, char **argv)

??

The answer to that has been discussed many times in this group...
 
V

Vitali Malicky

Hi!

Materialised said:
Hi,
I often see 2 different declairations of the main() function, and I am
unsure of the difference. They are
int main(int argc, char *argv[])
int main(int argc, char **argv[])

well, it's philosofical question...

first variant = argv[1][1] for example
second variant = *(*(argv+1)+1) and so on...

WBR, Life
 

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

Forum statistics

Threads
474,141
Messages
2,570,815
Members
47,361
Latest member
RogerDuabe

Latest Threads

Top