Home >Backend Development >C++ >Is Using a Dollar Sign ($) in C Variable Names Allowed?

Is Using a Dollar Sign ($) in C Variable Names Allowed?

DDD
DDDOriginal
2024-11-28 21:29:11760browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn