In fact, if you are using arrays, you are in fact using pointers. Both are closely related.
And your code is incorrect. You can't return a collection of value. What you can do is return a pointer and/or write in memory at a certain location where the calling function want you to do so. I'm quite sure the FAQ talks about pointers and arrays, maybe you should take a look.
So... if you want to do a "multiple return", (let's say we want a function that fill an array of integer with a certain value), here's a couple of equivalent examples
The "classic" version
Code:
int* fillArray(int array[], int nbElem, int value)
{
int i;
for (i = 0; i < nbElem; i++)
{
array[i] = value;
}
return array;
}
The "i love pointer" one
Code:
int *fillArray(int array[], int nbElem, int value)
{
int *ptr;
ptr = array;
while (ptr < array + nbElem)
{
*ptr = value;
ptr++;
}
return array;
}
The "recursive" one (hah..)
Code:
int *fillArray(int array[], int nbElem, int value)
{
if (nbElem < 1)
return NULL;
*array = value;
fillArray(array + 1, nbElem - 1, value);
return array;
}
And, last but not least, the x86-Visual Studio-specific one
Code:
int *fillArray(int array[], int nbElem, int value)
{
__asm
{
mov eax, value
mov edi, array
mov ecx, nbElem
rep stosd
}
return array;
}
By the way, don't look at the last 2 versions, especially the last one.