|
|
A brief summary of the syntax of declarators:
declarator: pointer[opt] direct-declaratordirect-declarator: identifier ( declarator ) direct-declarator [ constant-expression[opt] ]
direct-declarator ( parameter-type-list ) direct-declarator ( identifier-list[opt] )
pointer: * type-qualifier-list[opt] * type-qualifier-list[opt] pointer
char *p;p is a pointer to type char. p contains the address of a char object.
Care should be taken when pointer declarations are qualified with const:
const int *pci;declares a pointer to a const-qualified (``read-only'') int.
int *const cpi;declares a pointer-to-int that is itself ``read-only.''
char **t;t points to a character pointer.
int (*f)();f is a pointer to a function that returns an int.
void *A pointer to void may be converted to or from a pointer to any object or incomplete type, without loss of information. This ``generic pointer'' behavior was previously carried out by char *; a pointer to void has the same representation and alignment requirements as a pointer to a character type.
int ia[10];ia is an array of 10 integers.
char d[4][10];d is an array of 4 arrays of 10 characters each.
char *p[7];p is an array of seven character pointers.
The function srand returns nothing; it has a single parameter which is an unsigned int. The name seed goes out of scope at the ) and as such serves solely as documentation.
The function rand returns an int; it has no parameters.
The function strcmp returns an int; it has two parameters, both of which are pointers to character strings that strcmp does not change.
The function signal returns a pointer to a function that itself returns nothing and has an int parameter; the function signal has two parameters, the first of which has type int and the second has the same type as signal returns.
The function fprintf returns an int; FILE is a typedef name declared in stdio.h; format is a const qualified character pointer; note the use of ellipsis ( . . . ) to indicate an unknown number of arguments.