English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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.)

2006-07-23 07:39:51 · 2 answers · asked by KayP 2 in Computers & Internet Programming & Design

2 answers

Hi.

Because variables allocated instead a function are destroyed when that function returns/ends, you'll need to create & 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

2006-07-23 08:02:54 · answer #1 · answered by Leon Spencer 4 · 0 0

Try this link
http://www.thescripts.com/forum/thread61900.html

2006-07-23 07:58:39 · answer #2 · answered by medoelprinse 1 · 0 0

fedest.com, questions and answers