HTML

html content help to improve the coding

Tuesday, 27 March 2012

STACK OVERFLOW


STACK OVERFLOW

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:
 int f(){  g(); } int g() {  f();   } 
Stack overflow will happen only in static stack.

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++] =top


No comments:

Post a Comment