I'm relatively new to C and I'm having trouble returning an array from a function. Apologies if this have been answered elsewhere but I can't find it. I read somewhere about returning the first element and using a pointer to find the the other elements.
A simplified version of my code is:
This returns the first element but I don't know how to return the other elements.Code:int main() { int array[3]; array[0] = func(); } int func() { static int array[3]; array[0]=5; array[1]=6; array[2]=7; return array[0]; }



LinkBack URL
About LinkBacks



