473,796 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable Length

lak
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.?

Nov 3 '07 #1
13 7812
lak wrote:
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 limit is on identifiers, not just variable names; function names,
for instance, are also identifiers.

The 31 character limit is only on external identifiers. Internal
identifiers have a limit of 63 (5.2.4p1).

That limit is a minimum, not a maximum. "There is no specific limit on
the maximum length of an identifier." (6.4.1p2).

The minimum limit is a requirement on the implementor, not on the
developer. It means that if two external identifiers differ in their
first 31 characters, an implementation is required to recognize them as
being different. If the first difference occurs after the 31st
character, an implementation is allowed, but not required, to treat the
two identifiers as being the same, which usually causes problems
somewhere during compilation, unless it was only a typo, in which case
it can cause confusion in readers of the code.

A good compiler should warn you if you have two external identifiers
that differ only after the 31st character. A picky compiler might warn
you about even using identifiers longer than 31 characters. That's a
useful warning, because human readers can be easily misled into thinking
the whole identifier is meaningful, rather than just the first 31
characters.
Nov 3 '07 #2
lak wrote:
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 minimum limits are given in the C Standard. Implementations may
relax these restrictions further as appropriate.

PS. An identifier of hundred thousand characters is nothing short of
mad. Was there a reason for your pointless exercise?

Nov 3 '07 #3
James Kuyper wrote:

[...]
The limit is on identifiers, not just variable names; function names,
for instance, are also identifiers.

The 31 character limit is only on external identifiers. Internal
identifiers have a limit of 63 (5.2.4p1).
I'm rather sure that limit was far less before C99.

I don't have access to C89 std. here, but if memory serves me right,
minimum of 8 initial characters was significant (external identifiers).
--
Tor <torust [at] online [dot] no>

Nov 3 '07 #4
In article <fg**********@a ioe.org>, santosh <sa*********@gm ail.comwrote:
>lak wrote:
>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 minimum limits are given in the C Standard. Implementations may
relax these restrictions further as appropriate.

PS. An identifier of hundred thousand characters is nothing short of
mad. Was there a reason for your pointless exercise?
You might want to Google the words "test" and "experiment ".

You do get credit though for looking up and tranlating for us the Indian
numbering system.

Nov 3 '07 #5
Tor Rustad wrote:
James Kuyper wrote:

[...]
>The limit is on identifiers, not just variable names; function names,
for instance, are also identifiers.

The 31 character limit is only on external identifiers. Internal
identifiers have a limit of 63 (5.2.4p1).

I'm rather sure that limit was far less before C99.

I don't have access to C89 std. here, but if memory serves me right,
minimum of 8 initial characters was significant (external
identifiers).
I think it was six initial characters and case insensitive too. A
concession to the limitations of some of the linkers back then.

Nov 3 '07 #6
Tor Rustad wrote:
James Kuyper wrote:

[...]
>The limit is on identifiers, not just variable names; function names,
for instance, are also identifiers.

The 31 character limit is only on external identifiers. Internal
identifiers have a limit of 63 (5.2.4p1).

I'm rather sure that limit was far less before C99.

I don't have access to C89 std. here, but if memory serves me right,
minimum of 8 initial characters was significant (external identifiers).
That sounds about right; the limit was expanded in C99 because it was
felt to be no longer necessary to accommodate old linkers that didn't
support names longer than 8 characters.

However, I can't verify the precise number under the old standard. When
I wanted a copy of the C90 standard, it was way too expensive. By the
time it dropped down to a reasonable price, it was no longer the current
standard, and I was therefore no longer interested in it.
Nov 3 '07 #7

"lak" <la********@gma il.comwrote in message
>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.?
Typically a compiler will accept variables of any length until extreme
limits such as the amount of memory in the computer are hit.
However it is not obliged to accept more than 31 characters. That is a
concession to simple compilers. Nowadays the speed gain to be had from using
a fixed-size field is much less significant.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm
Nov 3 '07 #8
lak <la********@gma il.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_ident ifier
and
this_is_a_very_ very_long_ident ical 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_Keit h) 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"
Nov 3 '07 #9
santosh wrote:
Tor Rustad wrote:
>I don't have access to C89 std. here, but if memory serves me right,
minimum of 8 initial characters was significant (external
identifiers) .

I think it was six initial characters and case insensitive too. A
concession to the limitations of some of the linkers back then.
Yes, 6 significant initial characters it was.

I beleave one of our major production systems, still have that
limitation. This limit resulted in some terrible naming conventions.

--
Tor <bw****@wvtqvm. vw | tr i-za-h a-z>
Nov 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2751
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid = server.createobject("scriptlet.typelib").guid guid=Left(guid,instr(guid,"}")) genguid=guid
4
2589
by: sylvain.loiseau | last post by:
Hello Given a node set, I try to compute the total of the string-length value of each node. For instance, with : <xsl:for-each select="//q"> <!-- the length of each node is compute with: --> <xsl:value-of select="string-length(.)" />
5
11741
by: MLH | last post by:
I'm working with lots of long strings now, it seems. I have to import them & parse them constantly. The A97 memo field type supports only 32768 chars. What happens when this is processed... Dim MyString As String Am I getting VLS declaration or a FLS declaration? Can I control which I get somehow? I have done some homework, but I don't understand
5
14115
by: dam_fool_2003 | last post by:
Hai, I studied that the array size is fixed. But I come across a word called "variable length array". Is it possible to change the array size? So I tried the following: #include<stdio.h> #include<stdlib.h> int main(void) { int y = { 7, 9,10},i; for (;i<20;i++)
18
9403
by: Panchal V | last post by:
I want to access a variable length record in C, the format is as follows : +---+---+-----------+ | A | L | D A T A | +---+---+-----------+ A - Some Data (1 BYTE) L - Length the Data that follows (1 BYTE) then actual data
14
5850
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I want to store data like a database: ---------------------------------- Custumer:
19
2149
by: Skybuck Flying | last post by:
Hi, I think I might have just invented the variable bit cpu :) It works simply like this: Each "data bit" has a "meta data bit". The meta data bit describes if the bit is the ending bit of a possibly large structure/field.
8
3514
by: chellappa | last post by:
hi Everybody ! decalaring variable in a.h and using that vaaariable in a1.c and inalization is in main.c it is possible .........pleaase correct that error is it Possible? i am trying it gives error! In file included from main.c:2: a1.c:3: error: initializer element is not constant
6
2712
by: foreverbored75 | last post by:
Hello All! I am just learning c++ in school and I have the following question: Is there a way for the user to input the length of an array (console application) without using another variable? I made this program that finds the average of x number of numbers and stores the average in the last index of the array of the numbers. The other other variable I have is to determine the length of the array (totalNums). Is there a way to get...
3
4059
by: chandra.krothapalli | last post by:
Hi, I am writing a program to read database logs using db2Readlog/ db2ReadLogNoConn API. I am able to parse the data of "FIXED format data" and link them to appropriate columns for a given UPDATE/INSERT/DELETE. I am having difficulty in parsing the "Variable format data". In the log record I am not able find information about data length of each
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10217
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.