C Tutorials

61. Variable Scope and functions in C

By: Emiley J : 2007-09-22

Description: The functions and external variables that make up a C program need not all be compiled at the same time; the source text of the program may be kept in several files, and previously compiled routines may be loaded from libraries. Among the questions of interest are......


62. Static Variables in C

By: Fazal : 2007-09-22

Description: The variables sp and val in stack.c, and buf and bufp in getch.c, are for the private use of the functions in their respective source files, and are not meant to be accessed by anything else. The static declaration, applied to an external variable or function, limits the scope of that object to the rest of the source file being compiled. External static thus provides a way to hide names like buf and bufp in the getch-ungetch combination, which must be external so they can be shared, yet which should not be visible to users of getch and ungetch.


63. register Variables in C

By: Grenfel : 2007-09-22

Description: A register declaration advises the compiler that the variable in question will be heavily used. The idea is that register variables are to be placed in machine registers, which may result in smaller and faster programs. But compilers are free to ignore the advice.


64. Initialization of Variables in C

By: Henry : 2007-09-22

Description: In the absence of explicit initialization, external and static variables are guaranteed to be initialized to zero; automatic and register variables have undefined (i.e., garbage) initial values.


65. Recursion in C

By: Ivan Lim : 2007-09-22

Description: C functions may be used recursively; that is, a function may call itself either directly or indirectly. Consider printing a number as a character string. As we mentioned before, the digits are generated in the wrong order: low-order digits are available before high-order digits, but they have to be printed the other way around.


66. File Inclusion in C

By: Jagan : 2007-09-22

Description: File inclusion makes it easy to handle collections of #defines and declarations (among other things). Any source line of the form #include "filename"


67. Macro Substitution using #define in C

By: Kamini : 2007-09-22

Description: A definition has the form #define name replacement text


68. #if, #elif, #ifndef, #ifdef in C (Conditional Inclusion)

By: Lakshmi : 2007-09-22

Description: It is possible to control preprocessing itself with conditional statements that are evaluated during preprocessing. This provides a way to include code selectively, depending on the value of conditions evaluated during compilation.


69. Pointers and Function Arguments in C

By: Norman Chap : 2007-09-22

Description: Since C passes arguments to functions by value, there is no direct way for the called function to alter a variable in the calling function. For instance, a sorting routine might exchange two out-of-order arguments with a function called swap. It is not enough to write swap(a, b);


70. Pointers and Arrays in C

By: Priya : 2007-09-22

Description: In C, there is a strong relationship between pointers and arrays, strong enough that pointers and arrays should be discussed simultaneously. Any operation that can be achieved by array subscripting can also be done with pointers. The pointer version will in general be faster but, at least to the uninitiated, somewhat harder to understand.