7

Scope, Linkage, Lifetime and Storage Classes

Learning Objectives

In this chapter, you will learn about:

  • Scope and visibility of an identifier

  • Local variables and global variables

  • Linkage

  • Different types of linkages in C

  • The lifetime of an object

  • Different storage classes

  • How to allocate memory at the run time

7.1 Introduction

In the previous chapters, we have learnt about how to declare variables within a function and have seen that the amount of memory allocated to a variable depends upon its data type. We have restricted our discussion to the declaration of variables within a function (i.e. local variables) and have not discussed about the global variables (i.e. variables declared outside all the function definitions). The issues ...

Get Programming in C: A Practical Approach, First Edition 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.