I don't recall any such limitation in C (although it has been a while).
However, the compiler that you use to translate the C code into the machine
code most likely has some kind of limitation; it would vary from compiler
to compiler. So, why doesn't he just check it out for himself?? He can
write a basic "Hello, World" type of program and include variables with
different name lengths and see what his compiler will accept and not accept.
Dean Kukral
----- Original Message -----
From: "Frederick Navarro" <[log in to unmask]>
Sent: Sunday, August 06, 2006 8:32 PM
Subject: [PCSOFT] A 12 year old question....
I was asked by my nephew with such a silly question, but from an innocent
mind, for me, its quite valid. He is studying C programming language and
for members here who are programmers, maybe I could ask any of your input on
this question. The question is,
Does C or C++ have a limit/max capacity of the number of characters to be
used for its variable name? Take note, he is referring the variable name,
not the max value of the data type. For example, *"int My_Number"* declares
My_Number to be of integer data type which can hold values between -32767 to
+32766 more or less only. But his question is for the variable name, which
I just answered that it doesn't make any sense making a variable name say,
with more than 50 characters. He simply said, "Yeah, I understand. But
just for the sake of information, is there such a limit?". And this time I
was left hanging. Thanks for your thoughts.
Frederick Navarro
"Hold No Punches.." Rode brings you great shareware/freeware
programs with his honest opinions in this weekly column.
http://freepctech.com/rode
|