Arrays and Structures

Filter Course


Arrays and Structures

Published by: Zaya

Published date: 18 Jun 2021

Arrays and Structures Photo

Arrays and Structures

Array in C

An array is a collection of items stored at contiguous memory locations. An array of structures in C can be defined as the collection of multiple structures variables where each variable contains information about different entities. The array of structures in C are used to store information about multiple entities of different data types. The array of structures is also known as the collection of structures.

Array in C
Structure in C

A structure is a user-defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.
The structure is a collection of variables of different types under a single name. Similarly, the structure is another user-defined data type available in C that allows combining data items of different kinds.

 

In C, there are cases where we need to store multiple attributes of an entity. It is not necessary that an entity has all the information of one type only. It can have different attributes of different data types. For example, an entity Student may have its name (string), roll number (int), marks (float). To store such type of information regarding an entity student, we have the following approaches:

  • Construct individual arrays for storing names, roll numbers, and marks.
  • Use a special data structure to store the collection of different data types.

c
as