C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 309,233 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,750 people online right now. Registration is fast and FREE... Join Now!




about int main (int argc, char **argv)

 

about int main (int argc, char **argv)

zerogee

22 Aug, 2008 - 08:16 AM
Post #1

D.I.C Head
**

Joined: 20 Aug, 2008
Posts: 90

hi guys,

i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful smile.gif

User is offlineProfile CardPM
+Quote Post


Akelo

RE: About Int Main (int Argc, Char **argv)

22 Aug, 2008 - 08:22 AM
Post #2

D.I.C Head
**

Joined: 12 Dec, 2007
Posts: 80


My Contributions
QUOTE(zerogee @ 22 Aug, 2008 - 09:16 AM) *

hi guys,

i see this alot, but i've never used it in a program, and i dont know whats it used for, so if someone can help me i'll be thankful smile.gif


The main() is in many ways, nothing more than a glorified function, and those are variables that can be passed from the command line into the actual program.
User is offlineProfile CardPM
+Quote Post

gabehabe

RE: About Int Main (int Argc, Char **argv)

22 Aug, 2008 - 10:07 AM
Post #3

Black Scatmaster
Group Icon

Joined: 6 Feb, 2008
Posts: 8,882



Thanked: 177 times
Dream Kudos: 3275
Expert In: Lots of things.

My Contributions
A little more detail to shed a bit more light on the subject:

Basically, they are parameters, which are passed to the program from another program~ most commonly, the system shell (cmd if you are on Windows)

main()
The entry point into any console application. As you delve into graphics development, you'll notice that it isn't always this. However, to keep things simple, let's just stick with main on its own. smile.gif

int argc;
Stands for argument count. In other words, how many things are being passed into the program.

char **argv; or char *argv[];
Both do the exact same thing. Short for argument vector, or in other words, this is a multidimensional array that will store all arguments being passed to the function.

For a tutorial, click here.

Hope this helps smile.gif
User is offlineProfile CardPM
+Quote Post

wartech

RE: About Int Main (int Argc, Char **argv)

25 Aug, 2008 - 08:44 AM
Post #4

D.I.C Head
Group Icon

Joined: 16 Oct, 2006
Posts: 163



Thanked: 7 times
My Contributions
Thanks for the info gabehabe. I had been wondering about this myself.
User is offlineProfile CardPM
+Quote Post

gabehabe

RE: About Int Main (int Argc, Char **argv)

25 Aug, 2008 - 12:14 PM
Post #5

Black Scatmaster
Group Icon

Joined: 6 Feb, 2008
Posts: 8,882



Thanked: 177 times
Dream Kudos: 3275
Expert In: Lots of things.

My Contributions
Wow, I think it was worth posting about that. I've been thanked twice for it today alone! smile.gif
User is offlineProfile CardPM
+Quote Post

KYA

RE: About Int Main (int Argc, Char **argv)

25 Aug, 2008 - 12:26 PM
Post #6

while(sad){!sad; awesome();}
Group Icon

Joined: 14 Sep, 2007
Posts: 11,638



Thanked: 522 times
Dream Kudos: 2875
Expert In: C, C++, Java

My Contributions
its either a pointer to a pointer of arguments or a pointer to an array of them, not necessarily multidimensional
User is online!Profile CardPM
+Quote Post

gabehabe

RE: About Int Main (int Argc, Char **argv)

25 Aug, 2008 - 01:33 PM
Post #7

Black Scatmaster
Group Icon

Joined: 6 Feb, 2008
Posts: 8,882



Thanked: 177 times
Dream Kudos: 3275
Expert In: Lots of things.

My Contributions
But their behaviour simulates that of a multidimensional array, no matter how it is written. Correct?
User is offlineProfile CardPM
+Quote Post

KYA

RE: About Int Main (int Argc, Char **argv)

25 Aug, 2008 - 01:43 PM
Post #8

while(sad){!sad; awesome();}
Group Icon

Joined: 14 Sep, 2007
Posts: 11,638



Thanked: 522 times
Dream Kudos: 2875
Expert In: C, C++, Java

My Contributions
not explicitly, otherwise it would be written as [][], however you can allocate any memory you want, so yes it could be multidimensional

especially since an array declared with a [] is simply a pointer to the first object (implicit conversion)
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/26/09 08:52AM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month