From the course: C Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Understanding variable scope - C Tutorial
From the course: C Essential Training
Understanding variable scope
- [Instructor] A storage class sets a C language variable scope or its availability to functions in a source code file. Three key words define the classes. An auto variable is local or private to the function in which it's defined. This is a default class and the keyword auto is optional when declaring a variable. A static variable is similar to auto, but retains its value when the function quits. It too is local to the function in which it's defined. An extern variable exists outside of or external to a function, it's available to all functions. This type of variable is also known as a global variable. In this code, variables a and b are local to the sum function. Their values are used in this function then discarded when the function is done. Build and run to see how it works. And there's the output, nothing impressive. Still you've probably never seen a construction like the one shown here on line five. This is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Understanding C language data types3m 4s
-
(Locked)
Declaring variables2m 49s
-
(Locked)
Working with variables2m 55s
-
(Locked)
Exploring the printf() function3m 4s
-
(Locked)
Using constants2m 53s
-
(Locked)
Challenge: Make variables and constants47s
-
Solution: Make variables and constants1m
-
(Locked)
Understanding variable scope3m 8s
-
(Locked)
Making new data types3m 24s
-
(Locked)
Specifying characters and strings3m 17s
-
(Locked)
Specifying integers and real numbers4m 14s
-
(Locked)
Typecasting a variable3m 11s
-
(Locked)
Challenge: Basic I/O1m 10s
-
(Locked)
Solution: Basic I/O1m 35s
-
-
-
-
-