Thread: Issue with program that's calling a function and has a loop

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Just because you use variables with the same names in your main function and your convert function does not mean that they are related in any way, shape, or form.

  2. #2
    Registered User
    Join Date
    Nov 2008
    Posts
    4
    Quote Originally Posted by tabstop View Post
    Just because you use variables with the same names in your main function and your convert function does not mean that they are related in any way, shape, or form.
    Ok so even though I use the same variables in the convert function it doesn't mean they go back to the main()?

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by tigerfansince84 View Post
    Ok so even though I use the same variables in the convert function it doesn't mean they go back to the main()?
    All variables declared in a function are completely inaccessible outside that function (so anything declared in main is not visible in convert, and anything declared in convert is not visible in main). So you have two variables named total_converted_minutes, but they're never both defined at the same time.

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    4

    Question

    Quote Originally Posted by tabstop View Post
    All variables declared in a function are completely inaccessible outside that function (so anything declared in main is not visible in convert, and anything declared in convert is not visible in main). So you have two variables named total_converted_minutes, but they're never both defined at the same time.
    I see. So if they're not related how can I use the results from the function to apply to the loop in main? Or is that not possible?

Popular pages Recent additions subscribe to a feed