View Single Post
Old Oct 1st, 2006, 1:57 AM   #20
climbnorth
Newbie
 
Join Date: Oct 2006
Posts: 16
Rep Power: 0 climbnorth is on a distinguished road
Here is some example code for allocating memory for your records and then deleting it:

int iter = 0;
records *ptr;  /* For the array of records */
ptr = (record*)calloc(numRecords, sizeof(record));

for(i = 0; i < numRecords; i++)
{
  ptr[i] = (record)calloc(1, sizeof(record));
  /* if you need to allocate mem for record fields, do it here */
  /* copy record data here */
}

for(i = 0; i < numRecords; i++)
{
  /* if you allocated mem for record fields, delete them here */
  free(ptr[i]);
}
free(ptr);
climbnorth is offline   Reply With Quote