Thread: passing struct

  1. #1
    ignorance is blessing
    Join Date
    Sep 2006
    Posts
    13

    passing struct

    Hi,

    I am a bit confused about passing struct in C. Is it passing the entire struct or its just passing an pointer to itself. Thanks for any help.

  2. #2
    Eager young mind
    Join Date
    Jun 2006
    Posts
    342
    U can pass a pointer to the strucure u r interested in, to a function . Any standard book must explain that.
    In the middle of difficulty, lies opportunity

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well perhaps you need to go read "any standard book" then. It works both ways.
    Code:
    void passbyvalue( struct foo bar )
    {
        /* a copy of the structure is passed */
    }
    
    void passbypointer( struct foo *bar )
    {
        /* pass the address of the structure to the function */
    }
    It just depends on what way you want to go about it.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. Concatenating in linked list
    By drater in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 11:10 PM
  3. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 02:56 PM
  4. Passing a struct
    By Drainy in forum C Programming
    Replies: 3
    Last Post: 03-14-2005, 11:02 AM
  5. passing struct to function help
    By staticalloc in forum C Programming
    Replies: 4
    Last Post: 10-06-2004, 08:30 AM