Returning Arrays?

This is a discussion on Returning Arrays? within the C Programming forums, part of the General Programming Boards category; Is it possible to return an array, or more then one variable from a function? Thanks, Nathan...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    4

    Returning Arrays?

    Is it possible to return an array, or more then one variable from a function?

    Thanks,
    Nathan

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,259
    Is it possible to return an array, or more then one variable from a function?
    No. However, you can return a pointer to an array (but note that the array cannot be local to the function) or you can return a struct that consists of multiple values.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    95% of the cases when "you want to return an array", what should REALLY happen is that you pass an array INTO the function, and use the passed in array to fill in the data.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multidimensional arrays returning.
    By eXeCuTeR in forum C Programming
    Replies: 33
    Last Post: 07-01-2008, 01:27 PM
  2. Passing & Returning Arrays
    By jeffdavis_99 in forum C++ Programming
    Replies: 10
    Last Post: 04-02-2005, 06:44 PM
  3. Returning arrays from a function.
    By Jaken Veina in forum C Programming
    Replies: 14
    Last Post: 03-21-2005, 06:07 PM
  4. Functions returning char arrays
    By turmoil in forum C Programming
    Replies: 3
    Last Post: 05-27-2003, 02:43 AM
  5. Returning Entire Arrays
    By luckygold6 in forum C++ Programming
    Replies: 8
    Last Post: 03-15-2003, 06:54 AM

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