0
Can someone help me fix my code?
I've narrowed down the problem to being the local int array in the pickRandom function parameter, so how to I make it reference the address of the array? When I do that, it gives me an error about an array of references. https://code.sololearn.com/cVJNtdpMvDt9/?ref=app
8 Réponses
+ 1
it should be
int pickrand(int &arr[])
&should be used in parameter
+ 1
yeah right use * for array
+ 1
「HAPPY TO HELP」 yes, that's the main issue (sorry if I didn't make it clear)
+ 1
or you can modify your code a bit
int random = rand() % sizeof(ar)/sizeof(ar[0]); <- this part the bracket
0
「HAPPY TO HELP」 thanks, but this doesn't solve my problem.
the main problem I was having before is that the array it was generating as a reference only had 2 values in the array, so the random value could only generate 0 and 1, your code still does that
0
Sreejith I tried that, but then it tells me that it's an array of references, and I don't know what to do about that.
maybe I'll try trying that
0
Sreejith I'm trying that. could you please elaborate on what to do specifically? it keeps telling me that it can't convert int (*)[10] to int*
0
「HAPPY TO HELP」 thanks