I'm passing in some numbers, creating an array in that function, and then want to return that array.
I am just learning C, still a beginner, so if you could answer with sample code instead of just instructions, I'd really appreciate it! ("you quantize the pointer and pass in microfleems while maintaining the structure" would go right over my head.)
How do I return an array from a function written in C?
Hi.
Because variables allocated instead a function are destroyed when that function returns/ends, you'll need to create %26amp; return a REFERENCE/pointer to the array.
*ptrArray myFunction() {
myDataElement* myPtrArray = malloc(sizeof(myDataElement)+1);
/*
o what you want to the array
*/
return myDataElement;
}
You may need to correct me on the malloc() syntax. It's been awhile.
-Leon
Reply:Try this link
http://www.thescripts.com/forum/thread61...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment