Hello,
I need to complete an array based stack, that accepts the Pop function with the following prototype:
int Pop(void **item, char *type)
...
In my .h, I defined:
--------------------------
-
typedef struct
{
double* value;
} stackArr;
--------------------------
-
And then in my stack.c, I defined and declared:
--------------------------
-
#define STACK_SIZE 1000
static stackArr stack[STACK_SIZE];
static int numElements = 0;
--------------------------
-
I can get the Push function to work, but when I try the following Pop function:
int Pop(void **item, char *type)
{
if (numElements <= 0)
{
printf("\nPop failed.\n");
return FAIL;
}
*item = stack[numElements--].value
;
printf("\nItem (%d) popped successfully.\n", &item);
return SUCCESS;
}
...I get the printed test output such as "Item (-1079428920) popped successfully.
My main question is how to take:
int Pop(void **item, char *type)
...and assign a value to the void double pointer type. I can't change the function prototype.
(The char *type variable, declares if the value is an int or a double, but I have yet to find use for it)
Any help or contributions at all would be greatly appricated. Thank you so much. :)
Start Free Trial