Thread: variable names

  1. #1
    Registered User trekker's Avatar
    Join Date
    Mar 2002
    Posts
    46

    variable names

    what's the longest local and/or external name that i can use
    in a C program? What about C++ names ?
    Is n't system independent ?

    tia

    ps: i could have post this question in the C++ forum too, but
    i prefer this board

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Short answer: Compiler specific.

    Long answer: According to K&R Second Edition, a variable name may be of any length; however, only the first 31 characters are significant. Compilers are free to extend this beyond 31, and may make any number of characters significant.
    Jason Deckard

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >only the first 31 characters are significant
    For local variables, variables and functions with external scope are only guaranteed to be signifigant to the first 6 characters.

    -Prelude
    My best code is written with the delete key.

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Though I would recommend not to use very long names. They make code not very readable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random variable names
    By NeMewSys in forum C Programming
    Replies: 7
    Last Post: 06-12-2008, 11:26 AM
  2. global and static variable in a class delivered in a DLL
    By George2 in forum C++ Programming
    Replies: 16
    Last Post: 04-13-2008, 08:19 AM
  3. Random Variable names
    By Milhas in forum C Programming
    Replies: 14
    Last Post: 03-26-2008, 05:03 PM
  4. How to manage variable and function names
    By jefflieu in forum C++ Programming
    Replies: 14
    Last Post: 02-07-2008, 03:33 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM