I need to dynamically create a new Memo structure to hold memoized fib #'s
I have two structures
Code:
typedef struct HugeInteger
{
//array to hold the digits of a huge integer
int *digits;
//number of digits in the huge integer
int length;
} HugeInteger;
Code:
typedef struct Memo
{
// dynamically allocated HugeInteger array to store fib #'s
struct HugeInteger *F;
// current length of this array
int length;
} Memo;
So far my code for creating the new memo is the following..
Code:
Memo *createMemo(void){
int i;
Memo *memo;
memo=(Memo*)malloc(sizeof(Memo));
if(memo == NULL)
panic("ERROR: out of memory in createMemo()\n");
memo->F = (HugeInteger*)malloc(sizeof(HugeInteger)*INIT_MEMO_SIZE);
if(memo->F == NULL)
panic("ERROR: out of memory in createMemo()\n");
memo->length = INIT_MEMO_SIZE;
HugeInit(memo->F, 0);
HugeInit(memo->F, 1);
for(i=1; i<INIT_MEMO_SIZE; i++)
{
F->digits[i] == NULL;
}
F->length = 0;
return memo;
}
I am having trouble with initializing the struct inside of the new Memo, I need the digit fields to null and the length field to 0 to indicate that F[i] has not yet been memoized...I have F->digits and F->length in the for loop but this just simply doesn't work...
Please point me in the right direction so I can get this initialized...Thank you!