Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

What does dollar sign do in C?

The dollar sign $ is a valid identifier character in the Microsoft C++ compiler (MSVC). MSVC also allows you to use the actual characters represented by the allowed ranges of universal character names in identifiers. To use these characters, you must save the file by using a file encoding codepage that includes them.

Can dollar sign be used in C?

In GNU C, you may normally use dollar signs in identifier names. This is because many traditional C implementations allow such identifiers. However, dollar signs in identifiers are not supported on a few target machines, typically because the target assembler does not allow them.

What does '$' mean in coding?

When used in a regular expression, the dollar sign is used to represent the end of the line or string. For example, in the following Perl code, if the user's input stored in the $input variable ends with the "example," it would print "I see example." to the screen.

What does this symbol mean C?

Copyright: ©. When you write a "C" with a circle around the letter, or use the word "copyright," you are giving notice to the public that the work is copyrighted and that you are the owner of the work.


@ is generally invalid in C; it is not used for anything. It is used for various purposes by Objective-C, but that's a whole other kettle of fish.

$ is invalid as well, but many implementations allow it to appear in identifiers, just like a letter. (In these implementations, for instance, you could name a variable or function $$$ if you liked.) Even there, though, it doesn't have any special meaning.


To complete the accepted answer, the @ can be used to specify the absolute address of a variable on embedded systems.

unsigned char buf[128]@0x2000;

Note this is a non-standard compiler extension.

Check out a good explanation here


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.