Learn C Programming

Lesson 4 of 8 · Functions, Scope and Storage Classes

Module 7 · Functions, Scope and Storage Classes

Scope: Where a Name Lives

Free with an accountReading

Amara and David are writing Kenji's new game together. Amara's function counts the bonus levels, and David's counts the star levels. Both named their counter count.

Sign in to read

This lesson is free, with an account

An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.

What is inside Scope: Where a Name Lives

  1. Two functions, one name, no clash
  2. Block scope: a name lives inside its braces
  3. Lifetime: a local starts fresh on every call
  4. Shadowing: an inner name hides an outer one
  5. Global variables: visible everywhere, and that is the problem
  6. The honest global: a const