Thread: how to seperate two passed command line arguments...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    2

    how to seperate two passed command line arguments...

    not sure how to seperate them on the command line? i thought using quotes but doesn't work?

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    by whitespace

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Doesn't work how? Of course it works, depending on your shell of course.
    Code:
    zac@neux:~ (0) $ cat args.c
    #include <stdio.h>
    
    int main(int argc, char * argv[])
    {
       int i = 0;
    
       for(i = 0; i < argc; i++)
       {
          printf("Argument %d: %s\n", i, argv[i]);
       }
    
       return 0;
    }
    zac@neux:~ (0) $ gcc args.c -o args
    zac@neux:~ (0) $ ./args "this is the first 'argument'" "and then the second"
    Argument 0: ./args
    Argument 1: this is the first 'argument'
    Argument 2: and then the second
    Last edited by zacs7; 08-23-2009 at 06:41 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 03:27 PM
  2. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 06:46 AM
  3. No. of arguments passed?
    By vb.bajpai in forum C Programming
    Replies: 2
    Last Post: 06-16-2007, 05:30 AM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM
  5. arguments passed to main?!?
    By threahdead in forum C++ Programming
    Replies: 14
    Last Post: 01-22-2003, 08:43 PM

Tags for this Thread