Returning a 2 dimensional array from function
-
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.
-
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.
-
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.
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?