Could someone explain this?

Started by
16 comments, last by jHaskell 10 years, 1 month ago

Is there like any different between these two main functions? I was just exploring the internet looking at code and notice this small difference.


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

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

Advertisement
And this:

int main()

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy

Nah I know about declaring the type of function.

The spacing doesn't make a difference. Some people prefer to put the `*' with the `char' because they think of "pointer to char as the type". I prefer to put the `*' with the parameter name, because it is parallel to variable declarations, where the syntax of the language clearly associates the `*' with the variable.

Here's an example of this last point:
  char* a_pointer, another_pointer; // Actually, `another_pointer' is just a char!!

You can also write
int main(int argc, char * argv[])

I like to say char * a_pointer;

You can also declare it as int main(int argc char **argv);

http://stackoverflow.com/questions/3898021/mainint-argc-char-argv

And this:


int main()

Are you trolling now? Because, i can't tell if you are or if this is a question.

COOL! That solve one of my problem even if breaks the rules of pointers. You guys didn't notice args or does that not matter as well?

You guys didn't notice args or does that not matter as well?


Do you mean the name of the parameter? It can be anything you want. `argc' and `argv' are just traditional choices.

I just thought the name would have more important in a main function and it used a lot. Thanks for clearing this up

You can call it Sally if it makes you happy. laugh.png

This topic is closed to new replies.

Advertisement