1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    if i call a function and use a variable in it, will it still be set the next time i call the function or not. if not, how can i achieve that. do i have to define a global?

    See ya and thanks

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Alkmaar, The Netherlands
    Rep Power
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR> do i have to define a global?[/quote]

    Yes! Function variables are intended to only be used inside that function during the functions execution. When the function is finished the variable gets out of scope and its memory is freed. If you want to keep the result you thus have to define a global variable.

    Good luck,

    E-mail me at: b.vandermeijden@pecoma.nl
  4. #3
  5. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power
    Global is one way. However, if you aren't using the variable outside of the function, (or using it in a different context), think about using STATIC instead.

Similar Threads

  1. Replies: 2
    Last Post: February 10th, 2004, 11:03 PM
  2. problem with functions
    By veni123 in forum C Programming
    Replies: 8
    Last Post: February 5th, 2004, 02:22 PM
  3. functions and the passing of variables
    By keef0r in forum HTML Programming
    Replies: 1
    Last Post: January 25th, 2004, 02:42 PM
  4. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 2
    Last Post: January 9th, 2004, 02:26 PM
  5. Replies: 2
    Last Post: November 3rd, 2003, 01:20 PM

IMN logo majestic logo threadwatch logo seochat tools logo