C includes features that are often misunderstood and can therefore cause problems and unexpected results. This chapter talks about those tricky bits (pun intended!).
The Scope and Life of Variables
The scope of a variable defines where the variable can be used, while the life of a variable defines when it can be used. The two are not independent. They rather represent different ways of defining where a variable maintains its validity.
Broadly speaking, C supports two types of variables: local and global.
Local Variables
Local variables are defined within a function or a block statement. You can use them ...