Previous: Declaring Arrays and Pointers, Up: Variable Declarations [Contents][Index]
When multiple declarations have the same keywords and basetype, you can combine them using commas. Thus,
keywords basetype decorated-variable-1 [= init1], decorated-variable-2 [= init2];
is equivalent to
keywords basetype decorated-variable-1 [= init1]; keywords basetype decorated-variable-2 [= init2];
Here are some simple examples:
int a, b; int a = 1, b = 2; int a, *p, array[5]; int a = 0, *p = &a, array[5] = {1, 2};
In the last two examples, a
is an int
, p
is a
pointer to int
, and array
is an array of 5 int
s.
Since the initializer for array
specifies only two elements,
the other three elements are initialized to zero.