C Programming Language Quick Start Guide: Simplified C Programming For Beginners (C Programming, C Programming Language, C Programming for Absolute Beginner, ... For Beginners, Programming in C) by R.J. Khan

C Programming Language Quick Start Guide: Simplified C Programming For Beginners (C Programming, C Programming Language, C Programming for Absolute Beginner, ... For Beginners, Programming in C) by R.J. Khan

Author:R.J. Khan [Khan, R.J.]
Language: ita
Format: epub
Published: 2015-03-31T16:00:00+00:00


register

static

3.4.1 The Storage Class auto

By default, C variables declared within function definitions are automatic. Thus,

automatic is the most used of the four storage classes. If a compound statement starts

with able declarations, then these variables can be acted on within the scope of the

enclosing compound statement. For difference between compound statements starting

with declarations and those which do not start with variable declarations, we use block

terminology. A block is a compound statement with declarations.

Declarations within a block are automatically of storage class auto. We don’t need to

explicitly state auto for these variables. The keyword auto is rarely used. When the

program control enters a block, the system allocates memory for all the automatic

variables enclosed in the block. The variables are “local” in nature within that block.

When the program control exits a block, the system releases the memory that was set

aside for the automatic variables. As soon as the blocks are gone, gone are the variables.

That is why these variables are called local.

3.4.2 Storage Class extern

The communication between blocks is critical. One way of transmitting information

across your scope is using methods to pass parameters to another scope. But, this

method is not applicable in certain situations. The storage class extern provides us with

another mechanism for communication between different environments or scopes.

Declaration for a variable of extern class is very similar normal variable declaration

except that variables are declared outside any block. These variables act as global for all

the functions written after their declaration. An example follows for better

understanding:

int globalVariable = 10;

void printMe()

{



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.