/***************************************************************************
 *  Columbia University Introduction to Computer Programming in C COMS 1003
 *  Testing typedefs
 *
 *  Copyright (C) 2005 Michael E. Locasto
 *
 *  All rights reserved.
 *
 * $Id: typedeftest.c,v 1.1 2005/10/03 20:30:02 locasto Exp $
 **************************************************************************/
#include <stdio.h>
#include <stdlib.h>

/* You can equate a primitive type with a new type name. */
typedef int number;
/* You can reuse that new type name to define other types. */
typedef number* numbers;

/* Take a 'number' and return it as a 'number' */
number foo_function(number n)
{
   return n;
}

/**
 * If the following definition were uncommented, you would get this compile
 * error:
[michael@xoren code]$ make tt
gcc -Wall -g -o tt typedeftest.c
typedeftest.c:22: error: syntax error before "my_name"
typedeftest.c:22: warning: type defaults to `int' in declaration of `my_name'
typedeftest.c:22: warning: initialization makes integer from pointer without a cast
typedeftest.c:22: warning: data definition has no type or storage class
make: *** [tt] Error 1
 */
   //string my_name = "Michael";

/**
 *
 */
int main(int argc, char* argv[])
{
   number x = 0;
   number result = 0;

   typedef char* string;
   string arg = NULL;

   if(argc==2)
   {
      arg = argv[1];
      x = atoi(arg);
      result = foo_function(x);
      printf("%d\n", result);
   }else{
      printf("Invalid args.\n");
      return -1;
   }
   return 0;
}
