1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Arrays & Structures

Discussion in 'C' started by kanaks_go4ex, Aug 29, 2008.

  1. kanaks_go4ex

    kanaks_go4ex New Member

    Joined:
    Jun 11, 2008
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Can structures be passed to the functions by value?

    Why cannot arrays be passed by values to functions?

    Please explain.
     
  2. oogabooga

    oogabooga New Member

    Joined:
    Jan 9, 2008
    Messages:
    115
    Likes Received:
    11
    Trophy Points:
    0
    Yes, you can pass a struct by value, but it is rarely done.

    Presumably arrays cannot be passed by value for two reasons:
    1. Arrays can be huge, and since passing by value means
      making a copy of it, it would be very inefficient.
    2. The compiler does not know the size of a dynamic array.
    Actually, you can put a (non-dynamic) array into a struct
    and pass it by value that way!
     
  3. kanaks_go4ex

    kanaks_go4ex New Member

    Joined:
    Jun 11, 2008
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    can u give me an example for both the cases.
    thanx a lot.
     

Share This Page