HP C A.06.05 Reference Manual

Program Organization
Declarations
Chapter 2 19
initial_value
is an optional initializer for the variable.
Here are a few sample variable declarations without storage class specifiers or initial values:
int age; /* integer variable "age" */
int length, width; /* abbreviated declaration of two variables*/
float ph; /* floating-point variable "ph" */
char a_letter; /* character variable "a_letter" */
int values[10]; /* array of 10 integers named values */
enum days {mon, wed, fri}; /* enumerated variable "days" */
Typedef Declarations
C language allows you to create your own names for data types with the typedef keyword.
Syntactically, a typedef is similar to a variable declaration except that the declaration is
preceded by the typedef keyword.
A typedef declaration may appear anywhere a variable declaration may appear and obeys
the same scoping rules as a normal declaration. Once declared, a typedef name may be used
anywhere that the type is allowed (such as in a declaration, cast operation, or sizeof
operation). You can write typedef names in all uppercase so that they are not confused with
variable names.
You may not include an initializer with a typedef.
The following statement makes the name FOUR_BYTE_INT synonymous with long int:
typedef long int FOUR_BYTE_INT;
The following two declarations are now identical:
long int j;
FOUR_BYTE_INT j;
Abstract Global Types
Typedefs are useful for abstracting global types that can be used throughout a program, as
shown in the following structure and array declaration:
typedef struct {
char month[4];
int day;
int year;
} BIRTHDAY;
typedef char A_LINE[80]; /* A_LINE is an array of */
/* 80 characters */