Suppose consider a[10] as a stack, top is the last available elment in the stack, max is the index of the top i.e 9. Overflow will happen only at pushing en element. Here is the code.
push(int value)
{
if(top >= max)
printf("Stack overflow");
else
a[top++] = value;
}
Above answer was rated as good by the following members: zezond
In software stack will overflow when there will more amount of memory required to call the stack. As we all know in every language there are different rules with the memory requirement for the stack call.
In programming if the start On modern operating systems a typical stack has at least 1 megabyte which is sufficient for most purposes. Under anomalous conditions the program exceeds its stack limit. This causes a stack overflow. The two most common causes for a stack overflow is an infinite recursion as in:
Suppose consider a[10] as a stack top is the last available elment in the stack max is the index of the top i.e 9. Overflow will happen only at pushing en element. Here is the code.