Taking inputs at Command Line

This is a discussion on Taking inputs at Command Line within the C++ Programming forums, part of the General Programming Boards category; I have a problem. If my program is executed from the Command Prompt similar to: C:\some_directory\program.exe input1 input2 How do ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    1

    Taking inputs at Command Line

    I have a problem. If my program is executed from the Command Prompt similar to:

    C:\some_directory\program.exe input1 input2

    How do I access the extra inputs? I've tried messing around with everything and the only output I can get is how many inputs are done.

    Code:
    int main (int argc){
    cout << argc
    }
    with C:\ some_directory\program.exe input1 input2 input3

    returns 3.

    Thanks in advance.
    Stephen.

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by Stephenf
    Code:
    int main (int argc){
    cout << argc
    }
    This is not a valid prototype for main.
    It should be
    Code:
    int main (int argc, char ** argv){
       for ( int i = 0; i < argc; ++i )
          cout << argv[i] << endl;
       return 0;
    }
    Kurt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I validate these inputs?
    By Kyeong in forum C Programming
    Replies: 1
    Last Post: 10-19-2008, 03:20 PM
  2. checking inputs meets multiple conditions
    By 60beetle60 in forum C Programming
    Replies: 5
    Last Post: 04-19-2008, 09:25 AM
  3. I need help with validation for two inputs
    By KarrieWojo in forum C Programming
    Replies: 14
    Last Post: 12-20-2007, 11:55 AM
  4. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-07-2002, 12:28 AM
  5. Getting multiple inputs using cin
    By edk in forum C++ Programming
    Replies: 2
    Last Post: 09-13-2001, 03:34 PM

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