Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Variable Scope & Storage | C Programming Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 12 of 50

·c

Variable Scope & Storage Classes

9 mins

Course progress24%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `static` inside a function keeps the variable value between calls.
  • `extern` allows sharing a global variable across multiple `.c` files.
  • `register` is largely obsolete – the compiler decides register allocation.
  • Block scope limits a variable to the surrounding `{}`.

C defines storage duration and linkage via storage‑class specifiers.

SpecifierDescription
autoDefault for local variables (automatic storage).
staticPersists for the life of the program; internal linkage for functions/variables at file scope.
externDeclares a variable defined in another translation unit.
registerHint to store in a CPU register (ignored by modern compilers).
_Thread_localC11 thread‑local storage.

Scope describes visibility (block, file, function).

Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from C Programming FundamentalsBrowse activities
Previous lessonFunctions – Declaration & DefinitionContinue to lesson 13Pointers – BasicsBack to C Programming Fundamentals curriculum