If you can look at this list of ``a few basic types in C'' and say to yourself, ``Oh, how simple, there are only a few types, I won't have to worry much about choosing among them,'' you'll have an easy time with declarations. (Some masochists wish that the type system were more complicated so that you could specify more things about each variable, but those of us who would rather not have to specify these extra things each time are glad that we don't have to.)
Note that the basic types are defined as having at least a certain size. There is no specification that a short int will be exactly 16 bits, or that a long int will be exactly 32 bits. Some programmers become obsessed with knowing exactly what sizes things will be in various situations, and write programs which depend on things having certain sizes. Exact sizes are occasionally important, but most of the time we can sidestep size issues and let the compiler do most of the worrying.
Most of the simple variables in most programs are of types int, long int, or double. Typically, we'll use int and double for most purposes, and long int any time we need to hold values greater than 32,767. We'll rarely use individual variables of type char; although we'll use plenty of arrays of char. Types short int and float are important primarily when efficiency (speed or memory usage) is a concern, and for us it usually won't be.
Note that even when we're manipulating individual characters,
we'll usually use an int variable,
for the reason discussed in section 1.5.1
on page 16.
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1995, 1996 // mail feedback