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
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
Regards
scouseman
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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