Chapter 14. More on Data Types
THIS CHAPTER INTRODUCES YOU TO A data type that has not yet been described: the enumerated data type. You also learn about the typedef
statement, which enables you to assign your own names to basic data types or to derived data types. Finally, in this chapter you see the precise rules that are used by the compiler in the conversion of data types in an expression.
Enumerated Data Types
Wouldn’t it be nice if you could define a variable and specify the valid values that could be stored into that variable? For example, suppose you had a variable called myColor
and you wanted to use it to store one of the primary colors, red
, yellow
, or blue
, and no other values. This type of capability is provided by the enumerated data ...
Get Programming in C, Third 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.