CHAPTER 10

image

Structures

In this chapter, we will explain the following:

  • What a structure is
  • How to declare a structure
  • How to use typedef to work with structures more conveniently
  • How to work with an array of structures
  • How to search an array of structures
  • How to sort an array of structures
  • How to declare nested structures
  • How to use structures to manipulate fractions
  • How to use structures to store parallel arrays
  • How structures can be passed to a function

10.1 The Need for Structures

In C, a structure is a collection of one or more variables, possibly of different types, grouped together under a single name for convenient handling.

There are ...

Get Learn to Program with C now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.