C Parameter Example


/********************************************************************/
/*                                                                  */
/* This program has three parameters:                               */
/*                                                                  */
/*    1) Input/output parm.  This is a 20 byte character field.     */
/*       Replace the first 10 bytes of the field with our value.    */
/*                                                                  */
/*    2) Input parm.  This is a two byte binary number.             */
/*                                                                  */
/*    3) Output parm.  This is a two byte binary number.  Its       */
/*       value is parm 2 + 1.                                       */
/*                                                                  */
/********************************************************************/

#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>

main(int argc, char *argv[])
{
   char  parm1[20];
   short parm2,
         parm3;
   char  strng[10] = "Testing 3 ";

   memcpy(argv[1],strng,sizeof(strng));

   parm2 = * ((short *) argv[2]);

   parm3 = parm2 + 1;
   memcpy(argv[3],(char *) &parm3, 2);
}