returning arrays of structures

This is a discussion on returning arrays of structures within the C Programming forums, part of the General Programming Boards category; Hello can anyone help,,, I need to return an array of structures from a function after I handle it and ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Angry returning arrays of structures

    Hello

    can anyone help,,,
    I need to return an array of structures from a function after I handle it and change it...
    so my function accepts the array of structures as an argument and I want to return it...

    please help ...

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    arrays are automatically passed by reference. Any changes you make to the array in the function will be reflected back to the calling function.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Open to suggestions Brighteyes's Avatar
    Join Date
    Mar 2003
    Posts
    204
    need to return an array of structures from a function after I handle it and change it...
    so my function accepts the array of structures as an argument and I want to return it...
    You don't have to return it since an array parameter is converted to a pointer to the first element, any changes you make would be seen in the calling function anyway. But I've had plenty of times where I also returned the array for notational convenience, so you'd do it like this
    Code:
    struct T *f(struct T *t)
    {
        /* ... */
        return t;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 05-09-2009, 11:06 AM
  2. problem with arrays and structures
    By gell10 in forum C++ Programming
    Replies: 7
    Last Post: 11-02-2003, 11:02 PM
  3. Functions returning char arrays
    By turmoil in forum C Programming
    Replies: 3
    Last Post: 05-27-2003, 01:43 AM
  4. Returning Arrays
    By mr_spanky202 in forum C Programming
    Replies: 2
    Last Post: 04-06-2003, 02:57 PM

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