Storage Class Keyword Memory Location Default Value Scope Life Time
Storage Class Keyword Memory Location Default Value Scope Life Time
Storage classes are used to define things like storage location (whether RAM
or REGISTER), scope, lifetime and the default value of a variable.
2. Mention different type of storage classes.
1. auto storage class
2. extern storage class
3. static storage class
4. register storage class
#pragma token_name
13.Is there any difference that arises if double quotes , instead of angular
brackets are used for including the standard header file?
When include file in <> then it searches the specified file system directory.Ex.
#include<stdio.h>It will search stdio. h file in system directory.
When including file in “” Then it search this specified file in currently working directory.
PART C
1. Write any two common macro pitfalls with example program.
(i) Misnesting
When a macro is called with arguments, the arguments are substituted into the
macro body and the result is checked, together with the rest of the input file, for
more macro calls. It is possible to piece together a macro call coming partially
from the macro body and partially from the arguments. For example,
#define twice(x) (2*(x))
#define call_with_1(x) x(1)
call_with_1 (twice)
==> twice(1)
==> (2*(1))
The ability to piece together a macro call can be useful, but the use of
unbalanced open parentheses in a macro body is just confusing, and should be
avoided.
(ii) Operator Precedence Problems
You may have noticed that in most of the macro definition examples shown above, each
occurrence of a macro argument name had parentheses around it. In addition, another
pair of parentheses usually surround the entire macro definition. Here is why it is best to
write macros that way.
Suppose you define a macro as follows,
#define ceil_div(x, y) (x + y - 1) / y
whose purpose is to divide, rounding up. (One use for this operation is to compute how
many int objects are needed to hold a certain number of char objects.) Then suppose it is
used as follows:
a = ceil_div (b & c, sizeof (int));
==> a = (b & c + sizeof (int) - 1) / sizeof (int);
his does not do what is intended. The operator-precedence rules of C make it
equivalent to this:
a = (b & (c + sizeof (int) - 1)) / sizeof (int);