Sams Teach Yourself C in 21 Days

(singke) #1

DAY 12


WEEK 2


Understanding Variable


Scope


On Day 5, “Functions: The Basics,” you saw that a variable defined within a
function is different from a variable defined outside a function. Without know-
ing it, you were being introduced to the concept of variable scope,an important
aspect of C programming. Today you will learn:


  • About variable scope and why it’s important

  • What external variables are and why you should usually avoid them

  • The ins and outs of local variables

  • The difference between static and automatic variables

  • About local variables and blocks

  • How to select a storage class


19 448201x-CH12 8/13/02 11:17 AM Page 285

Free download pdf