C C ++ array .... need help understanding code

Could you explain this code? It seems to me a little confusing. Is "a" a double array? I would think that this is just an integer, but then in the cout expression it is used as a double array. Also in the condition of the for loop it says that <3 [b] / 3-3, it does not make any sense to me, however, the code compiles and runs. i just don't understand it seems syntactically wrong for me

int a,b[]={3,6,5,24};
char c[]="This code is really easy?";
for(a=0;a<3[b]/3-3;a++)
{
cout<<a[b][c];
}
+3
source share
9 answers

Wow. This is really funky. This is not a 2 dimensional array. it works because it cis an array, and in C there is an identifier that processes this

b[3]

same as this

3[b]

, while a < (24/3-3), 3[b] b[3], b [3] 24. a[b] ( b[a]) c.

, un-obfuscated

int a;
int b[] = {3,5,6,24}
char c[] = "This code is really easy?";
for (a = 0; a < 5; a++)
{
    cout << c[b[a]];
}

, b [4] , 3-, 5-, 6- 24- c

sco?

.

+6

- . a[b] b[a] *(a+b).

, index[array], array[index] , .

+7

, : int a int b[].

a[b][c] - c[b[a]], - : b[0] 0[b] .

+2
int a,b[]={3,6,5,24};

: int a ints b

char c[]="This code is really easy?";

char

for(a=0;a<3[b]/3-3;a++)

a [0..4]:

  • 3 [b] - b [3], 24.
  • 24/3 = 8
  • 8 - 3 = 5

cout << a[b][c];

:

  • a [b] b [a], b [0..4]
  • b [0..4] [c] - c [b [0..4]]
+2

, . a[3] , 3[a] c.

, :

int a,b[]={3,6,5,24};
char c[]="This code is really easy?";
for(a=0;a<b[3]/3-3;a++)
{
cout<<c[b[a]];
}
0

a < 3 [b]/3-3 - ,

a < [3]/3-3

a [b] , b [a], a sp b [a] {3,6,5,24}

, [b] [c] b [a] [c] c [{3,6,5,24}]

0

foo [bar] "" "* (foo + bar)" C. , a[b] b[a] ( ), ath b. a[b][c] c[b[a]] i.e. char c, - ath b.

0

- for.

b[3], *(b+3). *(b+3) *(3+b), 3[b]. , , :

for(a=0; a < ((b[3]/3) - 3); a++) 

b [3] (24), :

for(a=0; a < ((24/3) - 3); a++) 

for(a=0; a < (8 - 3); a++) 

, :

for(a=0; a < 5; a++) 

a 0-4. a[b][c], c [b [a]].

, , c[b[4]] - b 4 . , , .

0

: 'a' . , 0.

'3 [b] / 3-3' is 5. The loop will go from 0 to 4 using 'a'. ('3 [b]' is 'b [3]')

In step a == 4, 'a [b]' (so that 'b [a]') will be outside (the borders of "b" are 0..3), so it has undefined behavior. Sometimes on my computer a "segmentation error" is sometimes not. Up to this point, he displays: "soc?"

0
source

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


All Articles