#include <stdio.h>
#include <strings.h>

struct _record {
  char title[100];
  char filename[255];
  unsigned int example_num;
};

void process_record(struct _record *record)
{

  if ( record == NULL )
    {
      exit(1);
    }

  (void) printf("Processing record %d: %s\n", record->example_num, record->title);
  record->example_num++;

}

#define THIS_TITLE "Pass a structure by reference"
#define THIS_FILE "record_reference.c"
#define THIS_NUM 2

main()
{
  struct _record *example;

  example = (struct _record *) malloc ( sizeof (example) );

  (void) strncpy (example->title,
		  THIS_TITLE,
		  sizeof(THIS_TITLE) + 1);
  (void) strncpy (example->filename,
		  THIS_FILE,
		  sizeof(THIS_FILE) + 1);
  example->example_num=THIS_NUM;

  process_record(example);

  (void) printf("Example is number %d\n", example->example_num);

  free(example);

  exit(0);
}

