Node:Type errors, Previous:Typographical errors, Up:Errors
C supports a variety of variable types (different kinds of
variables for different kinds of data), such as integer
for
integer numbers, and float
for numbers with fractional parts.
You can even define your own types, such as total
for a sum, or
surname
for someone's last name. You can also convert a variable
of one type into other types. (This is called type coercion.)
Consequently, the type of a variable is of great importance to the
compiler.
C requires us to list the names and types of all variables that will be used in a program, and provide information about where they are going to be used. This is called declaring variables. If you fail to declare a variable, or use it as if it were a different type from the type it is declared to be, for example, by assigning a non-integer value to an integer variable, you will receive a compile-time error.
See Variables and declarations, for more information on variable declarations. See The form of a C program, for some simple examples of variable declarations.