Initializing Structure Variables in C

Structure Initialization

In this class, we will try to understand Initializing Structure Variables in C.

We have already discussed the basics of structures in our previous class.

Initializing Structure Variables

The image below is the programming example for Initializing Structure Variables.

Initializing Structure Variables in C Example
Example

In the above example, we have declared two variables stu1 and stu2.

The structure variables are initialized within flower braces.

The comma separates the values for the members, and a comma separates each variable initialization.

Memory Visualization

The image below is the visualization of storing the values the structure variables values on the memory.

Initializing Structure Variables in C Memory Visualization
Memory Visualization