array decay

Discussion in 'C Programming' started by Mantorok Redgormor, Sep 23, 2003.

  1. array doesn't decay when operand of sizeof, or & or when the array is
    a string or wide-string literal initializer.

    I understand the first two, but the thing about being used as an
    initializer means what? can someone give an example?


    - nethlek
     
    Mantorok Redgormor, Sep 23, 2003
    #1
    1. Advertising

  2. Mantorok Redgormor

    Kevin Bracey Guest

    In message <>
    (Mantorok Redgormor) wrote:

    > array doesn't decay when operand of sizeof, or & or when the array is
    > a string or wide-string literal initializer.
    >
    > I understand the first two, but the thing about being used as an
    > initializer means what? can someone give an example?


    It's talking specifically about string literals (which you may not realise
    are actually of array type), when used to initialise an array. Example:

    char a[20] = "Hello";

    I'm not quite sure why the standard feels the need to say that, as I thought
    such an initialiser was a special case anyway. I can't say I ever viewed it
    as an actual assignment of one array to another; I just thought of it as a
    specially recognised syntactical form.

    --
    Kevin Bracey, Principal Software Engineer
    Tematic Ltd Tel: +44 (0) 1223 503464
    182-190 Newmarket Road Fax: +44 (0) 1223 503458
    Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
     
    Kevin Bracey, Sep 23, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok Redgormor

    array decay

    Mantorok Redgormor, Oct 8, 2003, in forum: C Programming
    Replies:
    2
    Views:
    446
    Barry Schwarz
    Oct 9, 2003
  2. pandapower

    array to pointer decay question !!

    pandapower, Feb 2, 2004, in forum: C Programming
    Replies:
    5
    Views:
    576
    Horst Kraemer
    Feb 2, 2004
  3. frederik aa de jonge

    module for calculations involving radioactive decay?

    frederik aa de jonge, Nov 2, 2006, in forum: Python
    Replies:
    0
    Views:
    413
    frederik aa de jonge
    Nov 2, 2006
  4. m sergei

    array to pointer decay question !!

    m sergei, Jun 30, 2004, in forum: C Programming
    Replies:
    6
    Views:
    455
    Dan Pop
    Jul 1, 2004
  5. Snis Pilbor

    Question about function decay

    Snis Pilbor, Aug 4, 2006, in forum: C Programming
    Replies:
    5
    Views:
    288
    Flash Gordon
    Aug 5, 2006
Loading...

Share This Page