hi
i will give u a simple example of scope of local and staic variable

#include<stdio.h>
void print_value(void)

main()
{
 int i;
 for(i=0;i<=5;i++)
   {
     printf("iteration no:%d",i);
      printf_value();
  }

return 0;

}

void print_value(void)
  {
  static int x=0;
   int y=0;
  printf("values: x=%d ,y=%d\n",x++,y++);
  }

if u run this program output is:

iteration no:0 values :x=0,y=0
iteration no:1 values :x=1,y=0
iteration no:2 values :x=2,y=0
iteration no:3 values :x=3,y=0
iteration no:4 values :x=4,y=0
iteration no:5 values :x=5,y=0

1. difference is that local variable is created and destroyed each time when
function is called.
 but static variable retain the same value when that function is called.
 here y is always initialized to 0 when print_value is called but static
have same old value.

2.local variable is initialized every time but static variable is
initialized once need not reinitialized


On Thu, Aug 7, 2008 at 1:07 PM, kathir resh <[EMAIL PROTECTED]>wrote:

>   what is the diff between static int and int ...
>
> int main()
> {
> static int=5;
> i--;
> if(i)
> printf("returning main() %d",main());
> return 0;
> }
>
> plz explain th eprocess in detail.
>
> ---------------------------------
> Unlimited freedom, unlimited storage. Get it now
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]

Reply via email to