written 3.5 years ago by |
Header Files:
Including header file is done by a pre-processor directive. It includes a set of data and code from the source files. These are the files of a specific type i.e. to perform a set of similar operations. A header file has the extension of ".h".
For example to perform the manipulation of string data a special header file called as "string.h" is to be included. Similarly to perform various mathematical operations like sin, cosine, log etc. a header file "math.h" is to be included that has all these functions. Also for taking input from standard input device and to display output on a standard output device we have various header files like "conio.h", "stdio.h" etc.
Preprocessor directives:
These are used to include various files in the program, to define constants etc. These are files that contain a set of functions that when included give the available functions to be used in the program.
The various types of header files that can be included are code files, constant data files, string data files, initial data files, basic variable files, header files, etc.
- The code files are the .c files which have some functions or code written can be included in the program. These files have extension as 'c'.
- The constant files have extension as const and are used to store the constant values.
- The string files have the extensions "txt" or "str".
- The initialization files or the initial files are with the extension "data.
- The basic variable files are with the extension "bss".
Pre-processor directives are used to declare global variables and constants.
Macro functions:
To repeat a task for multiple times in a program we can use either functions (sub-routines) or macros. A macro is an in-line replacement of the call macro instruction in the program. Whenever the macro is called, the assembler or the compiler replaces the call macro instruction with the statements or the code within the macro. The difference between the macro and the function is that, the function is called and hence has a branching penalty. There is no branching penalty or the context switching penalty required in case of the macro.
Modifier:
There are various modifiers in C programming language. The data type modifiers like signed, unsigned, short and long specify the details of the range and the memory space allocated to the variable.
- Thus modifier "signed" indicates that the data can be positive as well as negative while the modifier "unsigned" indicates only positive numbers.
- Similarly, the modifier "short" indicates standard memory space while the modifier "long" indicates two byte extra space for the variable.
- The other modifiers like "auto", "static", "extern" and "register" indicate the storage location of the variable value and also indicates the life of the memory space allocated to the variable.
- The modifier "auto" indicates automatic or is the default variable declaration.
- The modifier "static" indicates the memory space to be reserved until the entire program execution and also retains the value. The "register" modifier is used to indicate the storage location to be inside the processor i.e. the register.
Linked Lists:
In this case each element has a pointer to its next element. The first element is pointed by a top pointer or the header pointer. No other element except the first element can be accessed directly i.e. the reach to the consecutive next elements, we need to go through its preceding elements.
Thus to read, delete, display or add an element, we need to traverse through the entire list through the pointers. It can be used to point to the series of tasks that are active and hence reach to the required task. It can also be used to have menu and sub-menu.