Passing Structures

This is a discussion on Passing Structures within the C++ Programming forums, part of the General Programming Boards category; I'm sorry guys, I swear this will be my last post of the day How would I return a structure ...

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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-06-2006, 12:06 AM
  3. passing structures to functions
    By AmazingRando in forum C++ Programming
    Replies: 5
    Last Post: 09-05-2003, 12:22 PM
  4. passing array of structures to function
    By bvnorth in forum C Programming
    Replies: 3
    Last Post: 08-22-2003, 08: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21