C Variables Length

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lak

    C Variables Length

    Hello firends.
    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.?

  • user923005

    #2
    Re: C Variables Length

    On Dec 14, 2:53 pm, lak <l...@nospam.in validwrote:
    Hello firends.
    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.?
    A more appropriate reference is the C language standard. It says:

    5.2.4.1 Translation limits
    1 The implementation shall be able to translate and execute at least
    one program that contains at least one instance of every one of the
    following limits:13)
    * 127 nesting levels of blocks
    * 63 nesting levels of conditional inclusion
    * 12 pointer, array, and function declarators (in any combinations)
    modifying an arithmetic, structure, union, or incomplete type in a
    declaration
    * 63 nesting levels of parenthesized declarators within a full
    declarator
    * 63 nesting levels of parenthesized expressions within a full
    expression
    * 63 significant initial characters in an internal identifier or a
    macro name (each universal character name or extended source character
    is considered a single character)
    * 31 significant initial characters in an external identifier (each
    universal character name specifying a short identifier of 0000FFFF or
    less is considered 6 characters, each universal character name
    specifying a short identifier of 00010000 or more is considered 10
    characters, and each extended source character is considered the same
    number of characters as the corresponding universal character name, if
    any)14)
    * 4095 external identifiers in one translation unit
    * 511 identifiers with block scope declared in one block
    * 4095 macro identifiers simultaneously defined in one preprocessing
    translation unit
    * 127 parameters in one function definition
    * 127 arguments in one function call
    * 127 parameters in one macro definition
    * 127 arguments in one macro invocation
    * 4095 characters in a logical source line
    * 4095 characters in a character string literal or wide string literal
    (after concatenation)
    * 65535 bytes in an object (in a hosted environment only)
    * 15 nesting levels for #included files
    * 1023 case labels for a switch statement (excluding those for any
    nested switch statements)
    * 1023 members in a single structure or union
    * 1023 enumeration constants in a single enumeration
    * 63 levels of nested structure or union definitions in a single
    struct-declaration-list

    So you can have up to 63 *initial* characters in an internal
    identifier. That means you might make one 100 characters long, but
    only the first 63 would be recognized to differentiate it from other
    identifiers.
    Some pre-C99 implementations may limit to 31 *initial* characters in
    an internal identifier. That means you might make one 100 characters
    long, but only the first 31 would be recognized to differentiate it
    from other identifiers.

    Comment

    • Ben Pfaff

      #3
      Re: C Variables Length

      lak <lak@nospam.inv alidwrites:
      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.
      The number of significant characters in an identifier varies
      among implementations . It is at least 31 for internal
      identifiers and 6 for external identifiers in C90, and higher
      than that in each case for C99.

      I don't know what a "lakh" is.
      --
      char a[]="\n .CJacehknorstu" ;int putchar(int);in t main(void){unsi gned long b[]
      ={0x67dffdff,0x 9aa9aa6a,0xa77f fda9,0x7da6aa6a ,0xa67f6aaa,0xa a9aa9f6,0x11f6} ,*p
      =b,i=24;for(;p+ =!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
      2:{i++;if(i)bre ak;else default:continu e;if(0)case 1:putchar(a[i&15]);break;}}}

      Comment

      • Eric Sosman

        #4
        Re: C Variables Length

        Ben Pfaff wrote:
        lak <lak@nospam.inv alidwrites:
        >
        >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.
        >
        The number of significant characters in an identifier varies
        among implementations . It is at least 31 for internal
        identifiers and 6 for external identifiers in C90, and higher
        than that in each case for C99.
        >
        I don't know what a "lakh" is.
        1E5, or GIYF.

        --
        Eric Sosman
        esosman@ieee-dot-org.invalid

        Comment

        • Richard Heathfield

          #5
          Re: C Variables Length

          Ben Pfaff said:
          lak <lak@nospam.inv alidwrites:
          >
          >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.
          >
          The number of significant characters in an identifier varies
          among implementations . It is at least 31 for internal
          identifiers and 6 for external identifiers in C90, and higher
          than that in each case for C99.
          >
          I don't know what a "lakh" is.
          According to Chambers Dictionary, it's 100,000.

          --
          Richard Heathfield <http://www.cpax.org.uk >
          Email: -http://www. +rjh@
          Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
          "Usenet is a strange place" - dmr 29 July 1999

          Comment

          • Default User

            #6
            Re: C Variables Length

            Ben Pfaff wrote:
            lak <lak@nospam.inv alidwrites:
            But I give 1 lakhs length to a variable, but my compiler doesn't say
            any error.
            I don't know what a "lakh" is.

            It was a surprise to me to find it in Merriam-Webster online:

            <http://m-w.com/dictionary/lakh>




            Brian

            Comment

            • CBFalconer

              #7
              Re: C Variables Length

              Eric Sosman wrote:
              Ben Pfaff wrote:
              >lak <lak@nospam.inv alidwrites:
              >>
              >>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.
              >>
              >The number of significant characters in an identifier varies
              >among implementations . It is at least 31 for internal
              >identifiers and 6 for external identifiers in C90, and higher
              >than that in each case for C99.
              >>
              >I don't know what a "lakh" is.
              >
              1E5, or GIYF.
              Around here it is assumed to be a hairy ruminant cloven-hoofed
              moss-eating cold-weather animal, with an evil taste. :-)
              (Endangered specied)

              --
              Chuck F (cbfalconer at maineline dot net)
              <http://cbfalconer.home .att.net>
              Try the download section.



              --
              Posted via a free Usenet account from http://www.teranews.com

              Comment

              • jaysome

                #8
                Re: C Variables Length

                On Fri, 14 Dec 2007 15:07:02 -0800, Ben Pfaff <blp@cs.stanfor d.edu>
                wrote:
                >lak <lak@nospam.inv alidwrites:
                >
                >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.
                >
                >The number of significant characters in an identifier varies
                >among implementations . It is at least 31 for internal
                >identifiers and 6 for external identifiers in C90, and higher
                >than that in each case for C99.
                So, if I declared functions with external linkage like the following
                in C90, then the behavior would be undefined, right?

                void *avl_t_first (struct avl_traverser *, struct avl_table *);
                void *avl_t_find (struct avl_traverser *, struct avl_table *, void *);

                I'm using a C90 compiler.

                If I use such code, could it format my hard drive?
                If I use such code, could it cause WWIII?
                If I use such code, on the Deathstation 9000, could it cause demons to
                fly out of my nose?
                If I use such code, could it cause Scott Nudds to come flying out of
                my nose?
                If I use such code, could it <insert your favorite consequence of
                undefined behavior here>?

                --
                jay

                Comment

                • santosh

                  #9
                  Re: C Variables Length

                  lak wrote:
                  Hello firends.
                  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.?
                  You asked this same question some time back. Couldn't you be bothered to
                  read the answers then given to you?

                  Comment

                  • Ben Pfaff

                    #10
                    Re: C Variables Length

                    jaysome <jaysome@hotmai l.comwrites:
                    So, if I declared functions with external linkage like the following
                    in C90, then the behavior would be undefined, right?
                    >
                    void *avl_t_first (struct avl_traverser *, struct avl_table *);
                    void *avl_t_find (struct avl_traverser *, struct avl_table *, void *);
                    >
                    I'm using a C90 compiler.
                    Much code assumes that more than 6 characters are significant in
                    external identifiers.
                    --
                    Ben Pfaff

                    Comment

                    • Francine.Neary@googlemail.com

                      #11
                      Re: C Variables Length

                      On Dec 14, 11:14 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
                      Ben Pfaff wrote:
                      lak <l...@nospam.in validwrites:
                      >
                      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.
                      >
                      The number of significant characters in an identifier varies
                      among implementations . It is at least 31 for internal
                      identifiers and 6 for external identifiers in C90, and higher
                      than that in each case for C99.
                      >
                      I don't know what a "lakh" is.
                      >
                      1E5, or GIYF.
                      In that case I'd advise the OP against using name of this length for
                      his variables - it might make his code hard to read, and the danger of
                      typos would be non-negligible. :)
                      >
                      --
                      Eric Sosman
                      esos...@ieee-dot-org.invalid

                      Comment

                      • santosh

                        #12
                        Re: C Variables Length

                        Francine.Neary@ googlemail.com wrote:
                        On Dec 14, 11:14 pm, Eric Sosman <esos...@ieee-dot-org.invalidwrot e:
                        >Ben Pfaff wrote:
                        lak <l...@nospam.in validwrites:
                        >>
                        >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.
                        >>
                        The number of significant characters in an identifier varies
                        among implementations . It is at least 31 for internal
                        identifiers and 6 for external identifiers in C90, and higher
                        than that in each case for C99.
                        >>
                        I don't know what a "lakh" is.
                        >>
                        > 1E5, or GIYF.
                        >
                        In that case I'd advise the OP against using name of this length for
                        his variables - it might make his code hard to read, and the danger of
                        typos would be non-negligible. :)
                        The OP is apparently a troll, as he posted the very same "question" a
                        while back, and got more than adequate responses. If he isn't a troll,
                        then, one is forced to the much more distressing conclusion that he is
                        incapable of learning and comprehension.

                        Comment

                        Working...