0
I'm trying to make a function to fill an array of int. The function of FillSeedArray();
I know that an array can't be passed to a function except by using a pointer. but I also want to try to make a class to hold info. I'm not sure where to start though. so here's what I want to do. I have a function, int FibMod(int nCurrent, int nLast, int nMax) { return (nCurrent + nLast) % nMax; } but I'm trying to change it so I can make a call like naSeeds[] = FibMod(...); I know it's all wrong, and a mess, which is why I need help. any info would be appreciated. I'll do more research on the mean time.
2 Answers
0
First thing first: you can pass an array to a functio without using pointers:
void function(int array[4]) {};
//You can even pass multidimensional arrays:
void multiarr(int array[][]){};
int main()
{
int arr[4];
function(arr);
return 0;
}
Second: can you share the code on code playground, and sharing it on this question?
0
I recently lost all my files, so I have to write it again. But now I'm trying to just to put the array, and a member function to fill it, into a class. so I'm guessing I can just use the this pointer. I'll rewrite it and post it at some point. I'm using anacode, and for some reason, the output is all zeros. Will repost soon.