Comparison Between a Union and a Structure

Differentiate between a union and a structure in this lesson.

We'll cover the following

Comparison

You have already seen that the declaration of the union data type and its variable is similar to the declaration of the structure in this lesson. The actual difference happens during memory allocation. Let’s compare the structure and union data types with a simple example.

Structure

See the code given below!

Get hands-on with 1400+ tech skills courses.