Advertisement

05.25.2008 at 05:16PM PDT, ID: 23431771
[x]
Attachment Details

Popping Array-based Stack w/ Double Pointer

Asked by sprockston in C Programming Language

Tags: C

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
 
 
Loading Advertisement...
 
[+][-]05.25.2008 at 05:30PM PDT, ID: 21644097

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C Programming Language
Tags: C
Sign Up Now!
Solution Provided By: evilrix
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.25.2008 at 05:38PM PDT, ID: 21644120

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 05:48PM PDT, ID: 21644150

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:04PM PDT, ID: 21644200

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:17PM PDT, ID: 21644224

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:19PM PDT, ID: 21644228

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:21PM PDT, ID: 21644232

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:29PM PDT, ID: 21644245

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:35PM PDT, ID: 21644256

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:35PM PDT, ID: 21644257

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 06:50PM PDT, ID: 21644293

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2008 at 10:57PM PDT, ID: 21644831

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628