Listing 4 Test Program

void main (void)
{
char b[32];                               // Buffer for user input
int size;                                 // Symbol size
int i;                                    // Loop counter
union                                     // Space for test symbol
  {
  SYMBOL x;
  char y[sizeof(SYMBOL)+255];
  } sym;

memset(&sym,0,sizeof(sym));               // Clear symbol area
printf("Symbol size? ");                  // Get symbol size from user
gets(b);
size = atoi(b);
if(size < 0) size = 0;                    // Make sure size is in bounds
if(size > 255) size = 255;
memset(sym.x.symbol,'X',size);            // Set symbol to X's

for(i = 0; savesym(&sym.x) != NULL; i++); // Allocate all memory
printf("\n%d symbols allocated\n",i);     // Print number of symbols
}