Results 1 to 3 of 3

Thread: The difference between int main() and int main(int argc, char* argv[ ])

  1. #1
    Join Date
    Jul 2014
    Posts
    95
    Thanks
    67

    Default The difference between int main() and int main(int argc, char* argv[ ])

    Hi!
    What difference is there between int main() and int main(int argc,char* argv[ ])?


    Why are arguments such as argc or argv[ ]?

    Thanks

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: The difference between int main() and int main(int argc, char* argv[ ])

    Base of C/C++ : look here

  3. The following user says thank you to Lesiok for this useful post:

    rezas1000 (8th August 2014)

  4. #3
    Join Date
    Aug 2014
    Posts
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: The difference between int main() and int main(int argc, char* argv[ ])

    short answer, int main() can't take command line arguements, while int main(int argc, char* argv[]) (or char **argv) can. argc is a count of arguements, which includes the executable name itself, so `nano foo` has argc of 2, nano and foo, and you would access those via argv[0] and argv[1] respectively.

  5. The following user says thank you to ntzrmtthihu777 for this useful post:

    rezas1000 (8th August 2014)

Similar Threads

  1. Replies: 6
    Last Post: 30th November 2012, 03:58
  2. QApplication(argc, argv)
    By SWEngineer in forum Newbie
    Replies: 4
    Last Post: 26th April 2011, 12:36
  3. Replies: 11
    Last Post: 11th August 2008, 09:14
  4. Replies: 15
    Last Post: 23rd March 2007, 16:16
  5. how to use "argc" and "argv" ?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2006, 19:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.