- #1
Peon666
- 108
- 0
What's wrong with this piece of code:
Whever I run it, it gives exception. There's some problem in this line but I can't igure what is it:
Here's the implementation of the push function:
What's the problem?
Code:
for (i=0; i!='\n'; i++)
{
if (isdigit(elements[i]))
{
array[i] = elements[i] - '0';
push(mystack, array);
}
}
Whever I run it, it gives exception. There's some problem in this line but I can't igure what is it:
Code:
push(mystack, array);
Here's the implementation of the push function:
Code:
int push (stackADT stack, stack_elem_t elem)
{
static int count;
if (count == MAX_STACK_DEPTH-1)
{
stack->stk = realloc(stack->stk,2*sizeof(struct stackCDT) );
MAX_STACK_DEPTH = 2*sizeof(struct stackCDT);
}
if (!stack) {
return (ADT_INVALID_STACK);
}
if (stack->stack_ptr == (MAX_STACK_DEPTH - 1)) {
return (ADT_STACK_FULL);
}
++stack->stack_ptr;
stack->stk[stack->stack_ptr] = elem;
return (ADT_NOERROR);
}
What's the problem?