Command line

This is a discussion on Command line within the Linux Programming forums, part of the Platform Specific Boards category; Hello How would I be able to read in a word off the command line and store it as a ...

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

    Command line

    Hello

    How would I be able to read in a word off the command line and store it as a variable? Thanks

    ex(prog name is test)
    test word
    -> I would like to store word into a variable



    Thanks

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    int main(int argc, char* argv[]);

    argc is the number of arguements. The first argument is the name of the program (in argv[0]), the second argument is whatever the second space delimited sequence was (and it's in argv[1]), the third is in argv[3], etc.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

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