ページ 11

識別子に利用できる記号を複数お教えください

Posted: 2021年4月28日(水) 00:39
by 大熊
識別子に利用できる記号を複数お教えください。アンダーバーの10と大文字のAである5は確実だと思います。

Re: 識別子に利用できる記号を複数お教えください

Posted: 2021年4月28日(水) 03:37
by box
全角文字はダメっすよ。

Re: 識別子に利用できる記号を複数お教えください

Posted: 2021年4月28日(水) 07:19
by みけCAT
コンパイラによっては、全角文字も使えることがあります。
https://wandbox.org/permlink/j9v5xoCXCBvZdRDS

N1570 6.4.2 Identifiers より引用

コード:

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
An implementation may allow multibyte characters
that are not part of the basic source character set to appear in identifiers; which characters
and their correspondence to universal character names is implementation-defined.
そもそも「C言語の」識別子だとは一言も書いてないですけどね…

Re: 識別子に利用できる記号を複数お教えください

Posted: 2021年4月28日(水) 07:25
by みけCAT
それよりも、1やAのような文字が「記号」に入るかどうかの方が難しい問題かもしれないですね…