Structures

Raheelanjum
3 min readJust now

A structure is a data type that can contain unlimited numbers of NAMED subcategories (or fields). For example, a student record may contain the student’s name, age, GPA, etc. Each category of information is defined by its name and type (e.g., name is a string, age is an integer). By placing all this information into a "structure," the computer is able to utilize it as a single "entity." In C, the fields and types must be defined before the structure is used.

Structures

Structures are very similar to Matlab, but must (like every other TYPE in C) be predefined.
A structure type is the name of a "grouping" of related pieces of "named" information about a single entity.
The syntax to DECLARE a structure TYPE is:

Here is an actual structure:

Remember, when creating a structure, every "field" (the named subcategories) must have a type!

Using a Structure

Once a structure has been defined, it can be used any place a standard TYPE can be used. Again, consider the structure Student defined above. To create it we use:

--

--

Raheelanjum
Raheelanjum

Written by Raheelanjum

Highly skilled and experienced content writer dedicated to crafting compelling, informative content that resonates with diverse audiences. Expertise spans blog

No responses yet