Chapter 17Programmer-Defined Data Types
We have been using the data types from C, such as int, char, or double. Data types provide valuable information about (1) The amount of memory space needed. For example, char is one byte; int is (usually) four bytes; double is eight bytes. (2) The types of operations. For example, int can be used in switch but double cannot.
C allows programmers to create new types for many reasons. The most obvious reason is to put related data together. For example, a college student has a name (string), year (integer), grade point average (floating-point), and so on.
17.1 Struct and Object
When multiple pieces of data are organized together, it is a structure. A structure is a type (similar ...
Get Intermediate C Programming, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.