Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C (https://www.askmehelpdesk.com/forumdisplay.php?f=438)
-   -   Scope of a variable (https://www.askmehelpdesk.com/showthread.php?t=641662)

  • Mar 7, 2012, 06:50 AM
    vgnndd
    Scope of a variable
    What is meant by the phrase "the scope of a variable" and how does it relate to subroutines and modules?
  • May 17, 2012, 02:08 AM
    camyyssa
    Useful read: http://en.wikipedia.org/wiki/Scope_(computer_science)
  • Oct 1, 2012, 09:35 AM
    WildProgrammer
    Hello!

    The scope of a variable mean wher in the program your variable will be accessible to your code. Depending where it is declare the scope will vary,if you declare it into a function it will be available only into that function, if you declare it into a loop you will be able to use it only into that loop, if you declare it before main() it will be global and accessible every where into the program but global variable are rarely the way to go.

    hope this was helpful

  • All times are GMT -7. The time now is 08:14 PM.