How it works...

The output of the preceding program will be something like this:

This represents the minimum and maximum values that a type can represent and the size in bytes for the current platform.

The C++ standard does not define the size of each type, but it does define the minimum width:

  • char: Minimum width = 8
  • short int: Minimum width = 16
  • int: Minimum width = 16
  • long int: Minimum width = 32
  • long int int: Minimum width = 64

This point has huge implications as different platforms can have different sizes and a programmer should cope with this. To help us get some guidance regarding data types, there is the concept of a data model. ...

Get C++ System Programming Cookbook 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.