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

Recap

Complex user-defined data types are commonly structs but can be other supported data types. The most common way to introduce them for use in a C program is to use the typedef keyword. They can be declared in the same way as any other data type—as a variable, as a reference to a variable, in an array, or as a memory block.

Structs are special because they allow you to store multiple pieces of heterogeneous data. In other words, you can store data fields inside the record that have different data types. As long as the data elements are of a known size, the entire record can be treated as a memory block.

This makes reading and writing them to and from files much easier. If the size of each field is not known at compile time, each member needs ...

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