Thread: Making a program take a variable number of arguments

  1. #1
    Registered User
    Join Date
    Apr 2007

    Making a program take a variable number of arguments

    I'm trying to write a program which takes a variable number of input file arguments at the command line, but I'm getting a little lost on how to do it. The program will basically need to take a variable number of files, get their lengths then write them concurrently to a single output file and create an index of where each input file can be found in the output file. That bit I can handle (I think) but I've never written any programs which take a non-set number of command line arguments.

    Googling brings up a load of stuff about vscanf, but I couldn't really unerstand what it was on about (or even if it was relevant), so any example code or help to do what I want to do would be great, cheers!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Nim Trainer
    By guesst in forum Game Programming
    Replies: 3
    Last Post: 05-04-2008, 04:11 PM
  2. Variable number of arguments in function.
    By kamoda_pawel in forum C Programming
    Replies: 1
    Last Post: 01-18-2007, 07:18 AM
  3. Can someone help me understand this example program
    By Guti14 in forum C Programming
    Replies: 6
    Last Post: 09-06-2004, 12:19 PM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM
  5. Replies: 3
    Last Post: 01-14-2003, 10:34 PM