The books i have already read :-

1. C ANSII Edition ( Cant understand their language )
2. C tutor
3. Pointers and memory ( Stanford )

Simple and Brief Command Line Tutorial
by Narue

Command line arguments are sent to a C program through two parameters in main. The first parameter specifies the number of command line arguments. The second parameter is an array of strings listing each command line argument:

#include <stdio.h>

int main ( int argc, char *argv[] )
  int i;

  /* Print the command line arguments */
  for ( i = 0; i < argc; i++ )
    puts ( argv[i] );

  return 0;

The first command line argument (argv[0]) is the program name. Subsequent command line arguments are the actual arguments sent to the program:

$ myprog -a foo some_arg

argv[0] = "myprog"
argv[1] = "-a"
argv[2] = "foo"
argv[3] = "some_arg"

This concludes the lesson on command line arguments. Yes, it's really that simple. :icon_rolleyes:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.