What do these stand for?

This is a discussion on What do these stand for? within the C++ Programming forums, part of the General Programming Boards category; Every example program in my book includes these parameters of main, could you tell me what they stand for? (I ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    3

    What do these stand for?

    Every example program in my book includes these parameters of main, could you tell me what they stand for?
    (I understand 'int, main, and char')

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

    arg= argument?

    So whats the 'c' and the 'v' after arg?

    The '*' and the '[]' are in the appendix in the back of my book, but I don't understand their uses here.

    Also what does the 'c' in cout stand for? The c'out' stands for 'output' right? I like to understand every part of the program, it's easier for me to learn so that's the reason I would like to know.

    Thank you for your time.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    arguement
    argument count
    pointer to array of argument variables[]
    console out

  3. #3
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Those are used for command line arguments (which are extra stuff you type on the command line to give more information to your program). If you don't use command line arguments, it is perfectly acceptable and somewhat more readable to skip that part:
    Code:
    int main()
    {
    }
    When you do learn about command line arguments, you can use the other way and it will make more sense. Basically, the first thing, argc, is the number of arguments, and the second thing is an array of C style strings constaining the actual arguments.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by misplaced
    arguement
    argument count
    pointer to array of argument variables[]
    console out
    I do believe (i might be wrong) that argv is argument vaules not variables as they could easily be placed into read only memory.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    yea..it probaby is values...but they are variables in my opinion
    because of the way you reference them in a program....and i don't believe they are constant....but honestly i don't know for sure one way or the other. my intent is not to argue it though.
    Last edited by misplaced; 10-04-2004 at 05:19 PM.

  6. #6
    #include<xErath.h> xErath's Avatar
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by paper-pant
    arg= argument?

    So whats the 'c' and the 'v' after arg?

    The '*' and the '[]' are in the appendix in the back of my book, but I don't understand their uses here.

    Also what does the 'c' in cout stand for? The c'out' stands for 'output' right? I like to understand every part of the program, it's easier for me to learn so that's the reason I would like to know.
    The name of a variable is completly independent from it's use, although they can be associated. argc is just a name for a variable that holds a integer. argv is in this case an array of char pointers
    You could have
    Code:
    int main(int numberofargumentstheusertyped, char *argumentstheusertyped[]);
    Both those name would be perfectly aceptable. What's important is what they hold.
    So cout is just a name of another variable, or object, that outputs text.
    The '*' and '[]' seem to be a bit more advanced than what you know...

  7. #7
    Registered User
    Join Date
    Jul 2004
    Posts
    101
    >arg= argument?
    >So whats the 'c' and the 'v' after arg?
    argc == argument count
    argv == argument vector

    In theory you may name the arguments whatever you like, argc and argv are merely common names and thus convenient. In practice, everyone expects argc and argv, so using different names may not be wise.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21