By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

Variable resets to zero

P: 3
I have this coded into a DLL file, it receives the initial "balance" from an external program. I tried to get the hibalance to always go up when balance goes up, but if balance goes down hibalance will remain as the highest it found. But the results are always balance = hibalance :mad: as if it's always getting reset. hibalance & cbalance are global variables defined higher up in the code structure.

Is there a way to save the value to a file or non volitle memory then retrieve it for the next iteration??

Expand|Select|Wrap|Line Numbers
  1. ////////////highest balance///////////////////
  2.  
  3. int topbalance (int hibalance)
  4.    {
  5.     cbalance =(int)gws("balance");       // assign balance to cbalance    
  6.     if (hibalance < cbalance); {           // compare - if false do nothing
  7.         hibalance = cbalance;               // if true
  8.           }
  9.     return hibalance;
  10.  }
How do I prevent the the variable hibalance from being reset to 0, simple but confused, any help would be a lifesaver. Tnx
Nov 5 '05 #1
Share this Question
Share on Google+
2 Replies


P: 3
Does anyone know how to save the above variable to say a txt file, then retrive it later for evaluation? :rolleyes:
Nov 6 '05 #2

P: 3
Another option I think. Should I be defining this as a STATIC. Would it preserve the value? Or am I not bringing the hibalance back into the function?
Nov 8 '05 #3

Post your reply

Sign in to post your reply or Sign up for a free account.