Command line options

This is a discussion on Command line options within the C Programming forums, part of the General Programming Boards category; Hello I have to input two strings from the command line, and then pass those words into a method. How ...

  1. #1
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    Command line options

    Hello

    I have to input two strings from the command line, and then pass those words into a method. How would I be able to accompish that

    Thanks.......

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    int main ( in argc, char **argv )

    argv is an array of strings that you will pass to another function. argv[0] is always the program name, any strings after that will be what you want to pass. So if your command line input was:
    c:\ programName string1 string2

    You would pass string1 and string2 like so:
    /* Function definition */
    void function ( char *stringOne, char *stringTwo );

    /* Function call */
    function ( argv[1], argv[2] );

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doxygen failing
    By Elysia in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 04-16-2008, 02:24 PM
  2. What's the best way to handle many program options?
    By stickmangumby in forum C Programming
    Replies: 19
    Last Post: 06-06-2007, 05:06 PM
  3. Options Dialog
    By Morgul in forum Game Programming
    Replies: 3
    Last Post: 11-16-2005, 12:15 AM
  4. Explorer options
    By Magos in forum Windows Programming
    Replies: 1
    Last Post: 04-02-2005, 09:23 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

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