Skip to content

docs: few minor changes. #4656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/c-language/array-declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ An "array declaration" names the array and specifies the type of its elements. I
*`declarator`*:\
&emsp;*`pointer`*<sub>opt</sub> *`direct-declarator`*

*`direct-declarator`*: /\* A function declarator \*/\
*`direct-declarator`*:\
&emsp;*`direct-declarator`* **`[`** *`constant-expression`*<sub>opt</sub> **`]`**

Because *`constant-expression`* is optional, the syntax has two forms:
Expand Down
20 changes: 10 additions & 10 deletions docs/c-language/interpreting-more-complex-declarators.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,31 @@ In this example, the steps are numbered in order and can be interpreted as follo

The following examples illustrate other complex declarations and show how parentheses can affect the meaning of a declaration.

```
```C
int *var[5]; /* Array of pointers to int values */
```

The array modifier has higher priority than the pointer modifier, so `var` is declared to be an array. The pointer modifier applies to the type of the array elements; therefore, the array elements are pointers to **`int`** values.

```
```C
int (*var)[5]; /* Pointer to array of int values */
```

In this declaration for `var`, parentheses give the pointer modifier higher priority than the array modifier, and `var` is declared to be a pointer to an array of five **`int`** values.

```
```C
long *var( long, long ); /* Function returning pointer to long */
```

Function modifiers also have higher priority than pointer modifiers, so this declaration for `var` declares `var` to be a function returning a pointer to a **`long`** value. The function is declared to take two **`long`** values as arguments.

```
```C
long (*var)( long, long ); /* Pointer to function returning long */
```

This example is similar to the previous one. Parentheses give the pointer modifier higher priority than the function modifier, and `var` is declared to be a pointer to a function that returns a **`long`** value. Again, the function takes two **`long`** arguments.

```
```C
struct both /* Array of pointers to functions */
{ /* returning structures */
int a;
Expand All @@ -81,28 +81,28 @@ struct both /* Array of pointers to functions */

The elements of an array cannot be functions, but this declaration demonstrates how to declare an array of pointers to functions instead. In this example, `var` is declared to be an array of five pointers to functions that return structures with two members. The arguments to the functions are declared to be two structures with the same structure type, `both`. Note that the parentheses surrounding `*var[5]` are required. Without them, the declaration is an illegal attempt to declare an array of functions, as shown below:

```
```C
/* ILLEGAL */
struct both *var[5](struct both, struct both);
```

The following statement declares an array of pointers.

```
```C
unsigned int *(* const *name[5][10] ) ( void );
```

The `name` array has 50 elements organized in a multidimensional array. The elements are pointers to a pointer that is a constant. This constant pointer points to a function that has no parameters and returns a pointer to an unsigned type.

This next example is a function returning a pointer to an array of three **`double`** values.

```
```C
double ( *var( double (*)[3] ) )[3];
```

In this declaration, a function returns a pointer to an array, since functions returning arrays are illegal. Here `var` is declared to be a function returning a pointer to an array of three **`double`** values. The function `var` takes one argument. The argument, like the return value, is a pointer to an array of three **`double`** values. The argument type is given by a complex *abstract-declarator*. The parentheses around the asterisk in the argument type are required; without them, the argument type would be an array of three pointers to **`double`** values. For a discussion and examples of abstract declarators, see [Abstract Declarators](../c-language/c-abstract-declarators.md).

```
```C
union sign /* Array of arrays of pointers */
{ /* to pointers to unions */
int x;
Expand All @@ -112,7 +112,7 @@ union sign /* Array of arrays of pointers */

As the above example shows, a pointer can point to another pointer, and an array can contain arrays as elements. Here `var` is an array of five elements. Each element is a five-element array of pointers to pointers to unions with two members.

```
```C
union sign *(*var[5])[5]; /* Array of pointers to arrays
of pointers to unions */
```
Expand Down