Structures in C language.

Structures in C language.

Learn from voice....

16/01/2021 11:25AM

Episode Synopsis "Structures in C language."

Structures in C language. Structures are used to create a user-defined datatype, which allows us to combine data of different types together. Structures helps to construct a complex data type, which is more meaningful. It is somewhat similar to an array, but an array holds data of similar type only. But structures on the other hand, can store data of any type, which is practically more useful. For example: If we have to write a program to store Student information, which will have Student's name, age, branch, permanent address, father's name etc, which included string values, integer values etc, how can we use arrays for this problem, we will require something which can hold data of different types together. In structures, data is stored in form of records. Defining a structure. struct keyword is used to define a structure. struct defines a new data type, which is a collection of primary and derived datatypes. Declaring Structure Variables. It is possible to declare variables of a structure, either along with structure definition or after the structure is defined. Structure variable declaration is similar to the declaration of any normal variable of any other datatype.  Accessing Structure Members Structure members can be accessed and assigned values in a number of ways. Structure members have no meaning individually without the structure. In order to assign a value to any structure member, the member name must be linked with the structure variable using a dot . operator also called period or member access operator. Structure Initialization. Like a variable of any other datatype, structure variable can also be initialized at compile time. Array of Structures. We can also declare an array of structure variables. in which each element of the array will represent a structure variable. Nested Structures. Nesting of structures, is also permitted in C language. Nested structures means, that one structure has another stucture as member variable. Structure as Function Arguments. We can pass a structure as a function argument just like we pass any other variable or an array as a function argument.

Listen "Structures in C language."

More episodes of the podcast Learn from voice....