Does At symbol (@) and Dollar Sign ($) has any special meaning in C or C++

后端 未结 3 426
攒了一身酷
攒了一身酷 2020-12-08 19:51

Recently one of my friend encountered this question in an interview. The interviewer asked him if the special characters like $, @, |, ^, ~ have any usage in c

3条回答
  •  天命终不由人
    2020-12-08 20:24

    To complete the other answers. The C99-Standard in 5.2.1.3:

    Both the basic source and basic execution character sets shall have the following members:

    the 26 uppercase letters of the Latin alphabet

    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

    the 26 lowercase letters of the Latin alphabet

    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

    the 10 decimal digits

    0 1 2 3 4 5 6 7 8 9

    the following 29 graphic characters

    ! " # % & ' ( ) * + , - . / : ; < = > ? [ \ ] ^ _ { | } ~

    All other characters maybe not even exist. (And should not be used)

    But there is also this point in the Common extensions: Annex J, J.5.2:

    Characters other than the underscore _, letters, and digits, that are not part of the basic source character set (such as the dollar sign $, or characters in national character sets) may appear in an identifier (6.4.2).

    Which is basically what duskwuff already wrote.

提交回复
热议问题