© Giulio Zambon 2016

Giulio Zambon, Practical C, 10.1007/978-1-4842-1769-6_2

2. Tricky Bits

Giulio Zambon

(1)Harrison, Aust Capital Terr, Australia

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 ...

Get Practical C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.