C –Structure

C structure is a collection of different types of data that is grouped together. It is used to represent records.Structkeyword is used to create a structure. Each element of a structure is called a member.

Syntax:

Example1:

Note: The given above example in which id, name, class, mob are the members of the structure, struct is a keyword and student is structure tag.

Example 2:

Output

Array of structure:

Example

Output

C –structure using Pointer

Dot(.) operator is used to access the data using normal structure variable and arrow( ->) is used to access the data using a pointer variable.

We can access the C structure in two ways.

  1. Using a normal variable
  2. Using pointer variable

Leave a Comment