C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to compare an old and new value w/o global variables Posted by Keith1394 on 25 Sept 2006 at 10:31 AM
Hello and thank you for your time,

I am trying to compare an old user entered value with a new user entered value from the same field (so logically they are calling the same function), but I cannot use global variables. How do I solve this problem, because local variables get initialized each time the function is called and then deleted when the function ends? I am sure this is a fairly common problem that has at least one very common solution. I only need the easiest solution to understand...Nothing fancy. Please help me!

Thank you,

Keith
Report
Re: How to compare an old and new value w/o global variables Posted by HK_MP5KPDW on 25 Sept 2006 at 10:56 AM
: Hello and thank you for your time,
:
: I am trying to compare an old user entered value with a new user entered value from the same field (so logically they are calling the same function), but I cannot use global variables. How do I solve this problem, because local variables get initialized each time the function is called and then deleted when the function ends? I am sure this is a fairly common problem that has at least one very common solution. I only need the easiest solution to understand...Nothing fancy. Please help me!
:
: Thank you,
:
: Keith
:

You must pass the variable(s) as arguments to the function.

Report
Use static variables... Posted by Mohammad Rast on 25 Sept 2006 at 7:34 PM
Hi Keith1394,

You can use 'static' variables, that is defined and get initialized once, in one place, and will remain until your program ends, just like a global variable, but its a local!
Report
Re: Use static variables... Posted by Keith1394 on 26 Sept 2006 at 4:45 AM
: Hi Keith1394,
:
: You can use 'static' variables, that is defined and get initialized once, in one place, and will remain until your program ends, just like a global variable, but its a local!
:

You are right!!! A static variable is my answer. Thank you!!!

-Keith



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.