Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is an expression including array subscripting can be an identifier?

int a[2][4] = {........};

In the code above, a is an identifier of array type. But I'm curious whether a[2], which is an array of 4 int elements, is also an identifier?

like image 441
Jin Avatar asked Apr 16 '26 17:04

Jin


1 Answers

a[2] is not an identifier.

The definition of identifiers in N1570 6.4.2 is

identifier:
    identifier-nondigit
    identifier identifier-nondigit
    identifier digit

identifier-nondigit:
    nondigit
    universal-character-name
    other implementation-defined characters

nondigit: one of
    _ a b c d e f g h i j k l m
      n o p q r s t u v w x y z
      A B C D E F G H I J K L M
      N O P Q R S T U V W X Y Z

digit: one of
    0 1 2 3 4 5 6 7 8 9

I don't think [ and ] are included in the "implementation-defined characters" for typical C compilers because they are used as array subscripting operator (N1570 6.5.2.1)

like image 174
MikeCAT Avatar answered Apr 19 '26 07:04

MikeCAT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!