Problem is probably obvious, it's late and I'm having trouble finding out why I'm getting some errors on this code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double pop (double stack, int *ptr);
void push (double stack, int *ptr, double x);
void main (void)
{
int *ptr;
int stackSize=0;
ptr=&stackSize;
double stack[4]={1.0, 2.0, 3.0};
push(stack, ptr, 9.0);
printf("%lf\n", pop(stack, ptr));
push(stack, ptr, 8.0);
push(stack, ptr, 7.0);
push(stack, ptr, 6.0);
printf("%lf\n", pop(stack, ptr));
printf("%lf\n", pop(stack, ptr));
printf("%lf\n", pop(stack, ptr));
}
double pop (double stack, int *ptr)
{
double value=0;
value=stack[*ptr];
--*ptr;
return value;
}
void push (double stack, int *ptr, double x)
{
stack[*ptr]=x;
++*ptr;
}
I'm most worried about
error C2143: syntax error : missing ';' before 'type'
on line
Code:
double stack[4]={1.0, 2.0, 3.0};
and the fact that I get
error C2065: 'stack' : undeclared identifier
everywhere I used stack, when it is clearly identified...