Originally Posted by
laserlight
Both stevesmithx and I asked you to post your current (i.e., most recent) code, not the code that you started out with.
Code:
double pop (double stack[], int *stackSize);
void push (double stack[], int *stackSize, double x);
int main (void)
{
double stack[4]={1.0, 2.0, 3.0};
int *stackSize;
int stackSz=0;
stackSize=&stackSz;
push(stack, stackSize, 9.0);
printf("%lf\n", pop(stack, stackSize));
push(stack, stackSize, 8.0);
push(stack, stackSize, 7.0);
push(stack, stackSize, 6.0);
printf("%lf\n", pop(stack, stackSize));
printf("%lf\n", pop(stack, stackSize));
printf("%lf\n", pop(stack, stackSize));
}
double pop (double stack[], int *stackSize)
{
double value=0;
value=stack[*stackSize];
--stackSize;
return value;
}
void push (double stack[], int *stackSize, double x)
{
stack[*stackSize]=x;
++stackSize;
}
I got it working, unfortunately the problem I started with in the beginning is still here...
Output is:
9.000000
6.000000
6.000000
6.000000
Press any key to continue . . .
If you can't tell, it's a problem with changing the value the pointer points too so I can get other values in the array.
[edit] - So I suppose the question is can I change the value the pointer points too without using a pointer to a pointer...