Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Returning a 2 dimensional array from function

Returning a 2 dimensional array from function

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structures
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IrishSonic
    wrote on last edited by
    #1

    Hi I have an array declared in function: char test[3][10]; How do I return this whole 2 dimensional array from a function?? Thanks.

    J D 2 Replies Last reply
    0
    • I IrishSonic

      Hi I have an array declared in function: char test[3][10]; How do I return this whole 2 dimensional array from a function?? Thanks.

      J Offline
      J Offline
      jason99
      wrote on last edited by
      #2

      try char **function()

      1 Reply Last reply
      0
      • I IrishSonic

        Hi I have an array declared in function: char test[3][10]; How do I return this whole 2 dimensional array from a function?? Thanks.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Just like you would any other pointer. Make sure that the array is either global, or a static variable. Otherwise, when the function goes out of scope, the variable is no longer valid. If the array is global, there really is no need for a function to return it, as all other functions would have access to it anyway. Read here for more.


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups