O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The struct Keyword

A struct is used to create a user-defined data type that can contain multiple items and yet be manipulated via a single variable name. It is akin to a RECORD in other programming languages, such as Pascal or Modula-2. For the uninitiated, imagine an address book entry. If the entry is a record, each piece of data is a field within that record.

Each member of the struct can be of a different data type, either a built-in type like an integer or an array of characters. The entire struct can be passed to functions but cannot be used directly in decision processes because it has an indeterminate type. You cannot even use an assignment or comparison operator between two structs, even if they are identically defined.

However, each ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required