Pages

July 21, 2010

Note that sizeof() takes a type, while sizeof takes a variable, object or expression. With some compilers, the two operators are interchangeable.

For normal usage, we may add the keyword auto (for automatic) to the definition


 auto int local = 2;

Since this is the default for any function parameter or any variable defined within a block, we seldom see this keyword in practice.

For very frequent usage, we add the keyword register to the definition


 register int local = 2;
static int local = 2;

External Linkage

A variable of static duration with external linkage can be shared by several modules. The compiler allocates memory for the variable in one module and the linker allows all modules access to that memory location. Each reference to the variable accesses the same memory location, regardless of the module from which the reference is made. To identify external linkage, we add the keyword extern to the declaration


extern int shared;


C Conversion Specifiers

The C language conversion specifiers for the int type used in calls to scanf() are

Specifier Input Value Argument Default Conversion
%c cc...c char* one or more characters
%d [-|+]dd...d int* signed decimal
%i [-|+][0[x]]dd...d int* signed integer
%u [-|+]dd...d unsigned* unsigned decimal
%o [-|+]dd...d unsigned* unsigned octal
%x [-|+][0x]dd...d unsigned* unsigned hexadecimal

No comments:

Post a Comment