Home >Backend Development >C++ >Is Using a Dollar Sign ($) in C Variable Names Allowed?
Variable Naming in C : Beyond Just Letters and Digits
In C , variable names are typically composed of alphabets, numbers, and underscores. However, encountering a variable name with a dollar sign ($) like int $TS may raise questions about its validity and permissibility.
According to the C standard, the only legal characters for variable names are alphanumerics and the underscore '_'. However, in practice, different implementations extend this list and may allow additional characters like '$'.
It's important to note that unicode alphabetic characters are also permitted by the standard. Nevertheless, most implementations have restrictions on the Unicode characters allowed. For maximum portability, it's advisable to use only standard characters like lowercase and uppercase unaccented letters (a-z, A-Z), digits (0-9), and underscores ('_').
The above is the detailed content of Is Using a Dollar Sign ($) in C Variable Names Allowed?. For more information, please follow other related articles on the PHP Chinese website!