Thread: What is the point of this

  1. #1
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138

    What is the point of this

    What is the point of using this:

    int main(argc,argv[])

    instead of using plain and simple int main()



    Thanx for ur time.

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    It allows you to send command line arguments to the program.
    So you could do something like this

    "myprog.exe command1 options"
    instead of asking the user inside the function what command / options they want to use

    and the correct syntax is
    int argv, char ** argc
    or
    int argv, char * argc[]

    either way gets compiled the same, the int argv tells you how many strings are in argc, so if you did this
    "myprog.exe one two three"
    argv = 4
    argc[0] = "myprog.exe" with a \0 at the end
    argc[1] = "one"
    argv[2] = "two"
    argv[3] = "three" all string have \0 appended to the end

    and you can call the variables whatever you want to, it just makes it easier for everyone else to read if you stick to the standard names

  3. #3
    Unregistered
    Guest
    and the correct syntax is
    int argv, char ** argc
    or
    int argv, char * argc[]
    You mean
    int main(int argc, char *argv[])
    or
    int main(int argc, char **argv)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help realy needed
    By ZohebN in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2008, 09:37 AM
  2. Getting a floating point exception
    By SnertyStan in forum C Programming
    Replies: 13
    Last Post: 03-25-2008, 11:00 AM
  3. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  4. floating point binary program, need help
    By ph34r me in forum C Programming
    Replies: 4
    Last Post: 11-10-2004, 07:10 AM
  5. point lies in circle?
    By cozman in forum Game Programming
    Replies: 3
    Last Post: 12-20-2001, 04:39 PM