Check the command line parameters : Command Line Parameters « Development « C / ANSI-C






Check the command line parameters

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  if(argc!=2) {
    printf("You forgot to type your name.\n");
    exit(1);
  }
  printf("Hello %s", argv[1]);

  return 0;
}
 

           
       








Related examples in the same category

1.Parse Arguements
2.A program to list the command line arguments
3.Process the command line input
4.Verify the user input and display file content
5.Check the command line input
6.Command line parameter: display all of them
7.Use the command line parameter
8.Check the command line parameter and use it
9.Check the command line parameter: if less than required exit