Thread: Passing Structures

  1. #1
    Autobots Transform! Dunners's Avatar
    Join Date
    Feb 2005
    Posts
    23

    Passing Structures

    I'm sorry guys, I swear this will be my last post of the day

    How would I return a structure from function a to function b so that I can acces the data members of the structure in function b?

    Cheers
    "Yes, I rather like this God fellow. He's very theatrical, you know, a pestilence here, a plague there. Omnipotence. Gotta get me some of that."
    - Stewie Griffin

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Return a pointer to that structure. Your function prototype would like
    Code:
    struct_type * function_name(...)
    Don't forget that when working with pointers to structures you need to use the -> operator instead of the . operator - it makes dereferncing MUCH easier.

  3. #3
    Autobots Transform! Dunners's Avatar
    Join Date
    Feb 2005
    Posts
    23
    Cheers boss! At last it's all working, I'm so happy I think I'll cry myself to sleep!
    "Yes, I rather like this God fellow. He's very theatrical, you know, a pestilence here, a plague there. Omnipotence. Gotta get me some of that."
    - Stewie Griffin

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with passing an array of structures by pointer
    By raptor1770 in forum C Programming
    Replies: 9
    Last Post: 11-29-2008, 11:01 AM
  2. Structures, passing array of structures to function
    By saahmed in forum C Programming
    Replies: 10
    Last Post: 04-05-2006, 11:06 PM
  3. passing structures to functions
    By AmazingRando in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2003, 11:22 AM
  4. passing array of structures to function
    By bvnorth in forum C Programming
    Replies: 3
    Last Post: 08-22-2003, 07:15 AM
  5. Passing structures... I can't get it right.
    By j0hnb in forum C Programming
    Replies: 6
    Last Post: 01-26-2003, 11:55 AM