how many number of character many be in a variable name?

This is a discussion on how many number of character many be in a variable name? within the C Programming forums, part of the General Programming Boards category; hi all, I have just started studying C and have gone up to variables. by the way, how many number ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    9

    how many number of character many be in a variable name?

    hi all,
    I have just started studying C and have gone up to variables.

    by the way, how many number of characters may be in an Identifier?

    I didn't find this anywhere, in a tutorial it is written that C Identifiers may be as long as we like but only the first 31 characters are significant.

    is it true?

    I am using DevC++ IDE in windows xp plateform.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,914
    The 1999 edition of the C standard states that "there is no specific limit on the maximum length of an identifier". Generally, I would say that you should not be worrying about this. Rather, worry about whether you are using appropriate and sufficiently descriptive names.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,668
    31 is the guaranteed minimum in C89.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User Cooloorful's Avatar
    Join Date
    Feb 2009
    Posts
    59
    I some C compilers of yester-year allow any number of characters to be used for variables but as far as the compiler was concerned only x number of characters were taken into account. So taking what Salem just said into account, C89 compliant compilers may allow you to have a variable with 102 characters in its name in use, but the compiler may only allow a maximum of 31 characters to be used to differenciate which variable is which. I would imagine when you start using variables with terribly similar names you also run the risk of your programs being difficult for the designer to maintain, not just something unmanageable for the compiler to understand.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fscanf with variable number of entries
    By cfdprogrammer in forum C Programming
    Replies: 5
    Last Post: 04-20-2009, 02:02 AM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  3. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  4. Edit a character string with an assigned variable
    By jeffdavis_99 in forum C++ Programming
    Replies: 2
    Last Post: 03-25-2005, 09:54 AM
  5. Creating a student grade book-how?
    By Hopelessly confused in forum C Programming
    Replies: 5
    Last Post: 10-03-2002, 08:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21