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

main()
{
  
  ENTRY item, *found_item;
  
  char string_key[30];
  int i = 0;

  hcreate(5000);
  
  /* put info in structure, and structure in item */
  item.key = "123456";
  item.data = (void *)5;
  if (hsearch(item, ENTER)==NULL)
    printf("insertion returned a NULL\n");
  else
    printf("insertion didnt return a NULL\n");

  item.key = "789012";
  item.data = (void *)6;
  if (hsearch(item, ENTER)==NULL)
    printf("insertion returned a NULL\n");
  else
    printf("insertion didnt return a NULL\n");
  
  item.key = "123456";
  item.data = (void *)7;
  if (hsearch(item, ENTER)==NULL)
    printf("insertion returned a NULL\n");
  else
    printf("insertion didnt return a NULL\n");
 

  /* access table */
  item.key = name_to_find;
  item.data=-1;
  if ((found_item = hsearch(item, FIND)) != NULL) 
    {
      printf("found %s, number = %d\n",
	     found_item->key,
	     ((struct info *)found_item->data)->age,
	     ((struct info *)found_item->data)->room);
    } 
  else 
    {
      printf("no such employee %s\n",
	     name_to_find);
    }
}



