Results 1 to 4 of 4

Thread: argc and argv

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default argc and argv

    Hi guys,

    I have three questions about argv and argc

    1.) argv and argc are used to save a step whereby if you didn't use them, once you hit enter in .cmd when executing a program you would need to get user input via cin for any variables that the program may need?

    2.) where do you get information about what arguments are permitted and in which order these arguments need to be inserted? This should be part of the documentation for a given program?

    3.) are argc and argv useless if you're developing a gui application?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: argc and argv

    Quote Originally Posted by Atomic_Sheep View Post
    1.) argv and argc are used to save a step whereby if you didn't use them, once you hit enter in .cmd when executing a program you would need to get user input via cin for any variables that the program may need?
    The commandline arguments have nothing to do with the standard input stream.
    One is a way to pass arguments to a program on start, one is a way for a program to read from the controlling terminal or from another program who's output is redirected/piped into the first program.

    Quote Originally Posted by Atomic_Sheep View Post
    2.) where do you get information about what arguments are permitted and in which order these arguments need to be inserted? This should be part of the documentation for a given program?
    Yes, or by the program itself is it can print usage information, e.g. when called with a certaing commandline argument or when called without any, etc.

    Quote Originally Posted by Atomic_Sheep View Post
    3.) are argc and argv useless if you're developing a gui application?
    Why would they be use less?
    A GUI application can also be started from commandline, a script or an OS factility that allows passing arguments.

    Cheers,
    _

  3. #3
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: argc and argv

    Quote Originally Posted by anda_skoa View Post
    The commandline arguments have nothing to do with the standard input stream.
    One is a way to pass arguments to a program on start, one is a way for a program to read from the controlling terminal or from another program who's output is redirected/piped into the first program.
    Yep understand they are separate, was just wondering why the command line functionality was added... the way I see it, it was added to save a step of having the user needing to input the data through cin, was just wondering whether my hunch was right.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: argc and argv

    The command line arguments are arguments you pass to the program at startup.
    As I said, this has nothing to do with programs having a standard input stream.

    Cheers,
    _

Similar Threads

  1. Replies: 5
    Last Post: 31st August 2014, 17:16
  2. Replies: 2
    Last Post: 8th August 2014, 20:08
  3. QProcess: Socket descriptor in argv[]
    By Jonny174 in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2012, 13:42
  4. QApplication(argc, argv)
    By SWEngineer in forum Newbie
    Replies: 4
    Last Post: 26th April 2011, 13:36
  5. how to use "argc" and "argv" ?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 9th December 2006, 20: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.