Making a program take a variable number of arguments

This is a discussion on Making a program take a variable number of arguments within the C Programming forums, part of the General Programming Boards category; I'm trying to write a program which takes a variable number of input file arguments at the command line, but ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    5

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,544
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 06: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, 09:34 PM

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