Thread: arguments

  1. #1
    Registered User
    Join Date
    Nov 2002


    how do i make my program use command line arguments? i want one to be an int, one to be a char, and the last to be a char array.

    something like this:

    programname help

    programname 5 5 #


  2. #2
    Registered User
    Join Date
    Jan 2003
    int main(int argc, char *argv[])
    argc is the number of arguments, including the program name, which is always the first argument.

    argv[0]..argv[argc-1] are the arguments in order as null terminated strings. The effects of wildcards, quotes and environmental variables depends on your compiler and shell. Some usefull functions are atoi() and the boost libraries lexical_cast

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 03:27 PM
  3. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 06:46 AM
  4. Replies: 10
    Last Post: 09-27-2005, 12:49 PM
  5. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM