Nested square brackets possible?

I came across k & r exercise 1.24, which says: "Write a program to test C program for rudimentary syntax errors such as inconsistent brackets, brackets and curly braces."

I am not sure how to handle the square brackets.

Are nested square brackets possible in ANSI C syntax? I have not seen them yet, but I am only in the first chapter.

+4
source share
3 answers

Of course, you can access the array at the location indicated in the second array. a[b[i]]

It is often used to sort buckets , where your buckets are the second array, and each bucket is an element in that array.

+9
source

Yes, it is possible:

 int index[] = {0,3,1,3}; int data[] = {9,10,22,34}; data[index[0]] = 0; data[index[1]] = 1; data[index[2]] = 2; data[index[3]] = 3; 
+3
source

Access to the array in the array is possible

 x[y[0]] //valid; 

But not for syntax inside an array

 x[[0]] //invalid; 
+1
source

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


All Articles