Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

char** v *char[] in C

As I read through C code, I often times see this:

int main(int argc, char **argv)

but I always learned to do this:

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

So, why would I use one over the other? I know they’re technically different, but I don’t see quite why I’d use one as opposed to the other.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks in advance.

>Solution :

Functionally, for the purposes of access to the arguments, those two notations are equivalent.

The [] notation may have a marginal benefit of distinguishing between a pointer to a single element and a pointer to an array; the char** can be misread as an out-parameter of type char*.

Unlikely with main()‘s argv though.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading