lak <la********@gmail.comwrites:
I want to know what is the variable length in c.
I K&R they stated that atleast 31 character.
But I give 1 lakhs length to a variable, but my compiler doesn't say
any error.
It accepts it.Then what is the maximum length to a variable name.?
The C90 standard requires compilers to support a minumum of 31
significant initial characters in an internal identifier or macro
name, 6 in an external identifier. I recall that external identifiers
that differ only in case ("foo" vs. "Foo") are not required to be
treated as distinct, but in a quick look at the C90 standard I didn't
find a reference to that.
C99 increases this to 63 characters for internal identifiers, 31 for
external identifiers. I believe that identifiers differing only in
case are required to be treated as distinct, but again, I didn't find
a reference to that in the standard (I'm sure it's there, I just
didn't take the time to find it).
However, compilers aren't required to impose these restrictions; these
are just the minimum they're required to support. A compiler that
allows identifiers of any arbitrary length meets the standard's
requirements. Furthermore, even if the compiler imposes limits, the
limit is on the initial significant characters, not on the full length
of the identifier. For example, a compiler might allow both
this_is_a_very_very_long_identifier
and
this_is_a_very_very_long_identical identifier
as external identifiers, but treat them as the same (because they
match in the first 31 characters). A compiler may (but need not)
impose a limit of at least 509 characters (C90) or 4095 (C99)
characters in a logical source line, and an identifier can't span more
than one source line -- but again, a compiler isn't required to impose
any limit at all.
Incidentally, most people here aren't likely to know that "lakh" means
one hundred thousand; the word is rarely used outside India.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"