试试一个变量名最长可以有多长?

In computer languages, identifiers are tokens (also called symbols) which name language entities. Some of the kinds of entities an identifier might denote include variablestypeslabelssubroutines, and packages.

Which character sequences constitute identifiers depends on the lexical grammar of the language. A common rule is alphanumericsequences, with underscore also allowed, and with the condition that it not begin with a digit (to simplify lexing by avoiding confusing with integer literals) – so foo, foo1, foo_bar, _foo are allowed, but 1foo is not – this is the definition used in earlier versions of C, and many other languages.

Reserved keywords

The following words are reserved, and may not be used as identifiers:

auto
_Bool
break
case
char
_Complex
const
continue
default
do
double
else
enum
extern
float
for
goto
if
_Imaginary
inline
int
long
register
restrict
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while

Implementations may reserve other keywords, such as asm, although implementations typically provide non-standard keywords that begin with one or two underscores.

Case sensitivity

C identifiers are case sensitive (e.g., fooFOO, and Foo are the names of different objects). Some linkers may map external identifiers to a single case, although this is uncommon in most modern linkers.

Comments  

# yuanyuan 2021-09-23 09:26
老师,请问有原文出处吗
# Moderator 2021-09-23 11:19
en.wikipedia.org

You have no rights to post comments