Check the command line parameter and use it : Command Line Parameters « Development « C / ANSI-C






Check the command line parameter and use it

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

int main(int argc, char *argv[])
{
  double pounds;

  if(argc!=2) {
    printf("Usage: CONVERT <ounces>\n");
    printf("Try Again");
  }
  else {
    pounds = atof(argv[1]) / 16.0;
    printf("%f pounds", pounds);
  }

  return 0;
}


           
       








Related examples in the same category

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