Explain why these two multidimensional arrays seem to be true syntax, but only one gives the expected results?

I just realized the error of my methods in a bit of code that fills a 2-dimensional array with c.

I declared an array as follows:

int myArray[5][5];

.. but mistakenly set the value with

*myArray[3,4] = 10;

.. when it was supposed to be:

myArray[3][4] = 10;

Well, the first line is an error, but it compiled and started, although with very strange results. (ie when I tried to print the contents of * myArray [3,4], it had the wrong value)

Can someone explain what exactly this first assignment operator does?

edit: I initially tried to use:

myArray[3,4] = 10;

.., , int * int. , 3,4-4 , 4 , -.

+3
2

: (a, b) - b: http://en.wikipedia.org/wiki/Comma_operator

*myArray[3,4] *myArray[4]

+7

* myArray [3,4] = 10;

C, " ", . , 3 4. , :

* myArray [4] = 10;

, .

0

Source: https://habr.com/ru/post/1788851/


All Articles