Persistant Variables

 
Hi

Can somebody please tell me how to define a persistant variable i.e a variable that maintains it's value through each loop of the code and is not reset.

Many Thanks
scouseman
 
Hi

Can somebody please tell me how to define a persistant variable i.e a variable that maintains it's value through each loop of the code and is not reset.

Many Thanks
scouseman


There are two ways how you can accomplish that.
(a) Use "static" if only one function will use this value.
(b) Declare variable outside of start() or any function which will use this variable.

int flag;

....

int start()
{
flag=10;
....
}

int somefunc()
{
static int flag=10;
....
return(flag);
}
 
Many Thanks sub, your help was much apprciated
Regards
scouseman