Syntax with Example C Programs
Subject and UNIT: Programming in C: Unit IV: Structures and Union
Self-referential structures are those structures that contain a reference to data of its same type, i.e., in addition to other data, a self-referential structure contains a pointer to a data that is of the same type as that of the structure.
with Example C Programs
Subject and UNIT: Programming in C: Unit IV: Structures and Union
For structures to be fully useful, we must have a mechanism to pass them to functions and return them.
with Example C Programs
Subject and UNIT: Programming in C: Unit IV: Structures and Union
In the above examples, we have seen how to declare a structure and assign values to its data members. Now we will discuss how to declare an array of a structure. For this purpose, let us first analyse, where we would need array of structures.
with Example C Programs
Subject and UNIT: Programming in C: Unit IV: Structures and Union
A structure can be placed within another structure, i.e., a structure may contain another structure as its member. A structure that contains another structure as its member is called a nested structure.
with Example C Programs
Subject and UNIT: Programming in C: Unit IV: Structures and Union
A structure is similar to records. It stores related information about an entity. A structure is a user-defined data type that can store related information (even of different data types) together.
Programming in C
Subject and UNIT: Programming in C: Unit III (b): Pointers
Although pointers are very useful in c they are not free from limitations. If used incorrectly, pointers can lead to bugs that are difficult to unearth.
with Example C Programs
Subject and UNIT: Programming in C: Unit III (b): Pointers
The process of allocating memory to the variables during execution of the program or at run time is known as dynamic memory allocation. C language has four library routines which allow this function.
Programming in C
Subject and UNIT: Programming in C: Unit III (b): Pointers
Before jumping into dynamic memory allocation, let us first understand how memory is used. Conceptually, memory is divided into two-program memory and data memory
Subject and UNIT: Programming in C: Unit III (b): Pointers
Static allocation When we declare a static or global variable, static allocation is done for the variable.
with Example C Program
Subject and UNIT: Programming in C: Unit III (b): Pointers
In C language you are also allowed to use pointers that point to pointers. The pointers in turn, point to data (or even to other pointers). To declare pointers to pointers, just add an asterisk (*) for each level of reference.
with Example C Program
Subject and UNIT: Programming in C: Unit III (b): Pointers
When an array of function pointers is made, the appropriate function is selected using an index. The code given below shows the way to define and use an array of function pointers in C.
with Example C Programs
Subject and UNIT: Programming in C: Unit III (b): Pointers
C allows operations with pointers to functions. We have seen earlier in this chapter that every function code along with its variables is allocated some space in the memory. Thus, every function has an address.