If you want to pass parameters from a shell to a program written in C, you can use the mechanism shown in the following piece of C code.

#include <stdio.h>

 * This program will simply list the arguments provided through the shell.
 * argc: count of arguments from shell
 * argv: parameters given through shell, given as strings seperated by blanks
int main(int argc, char *argv[]) {
  int i;

  printf("number of given arguments: %d", argc);

  for(i=0; i < argc; i++) {
    printf("\nparameter no %d: %s ", i, argv[i]);


Tagged on: