Mr'Black - 9 months ago 40

C Question

I am trying to read correctly this :

`*(strarray[i]+j)=0;`

I was understanding something like :

`strarray[i][++j] = 0;`

or

`strarray[i][++j] = '\0';`

but is not exactly the same. How could it be written correctly as an array subscripting notation?

Answer

Using the postfix array subscripting notation,

```
*(strarray[i]+j)=0;
```

will be

```
strarray[i][j]=0;
```

Quoting the `C11`

standard, chapter §6.5.2.1, *Array subscripting*

A postfix expression followed by an expression in square brackets

`[]`

is a subscripted designation of an element of an array object. The definition of the subscript operator`[]`

is that`E1[E2]`

is identical to`(*((E1)+(E2)))`

. [...]

In your case, you can consider `E1`

as `strarray[i]`

and `E2`

as `j`

.

Source (Stackoverflow)