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

12th May 2018, 3:40 PM
fallOut015
fallOut015 - avatar
8 Answers
+ 1
it should be int pickrand(int &arr[]) &should be used in parameter
12th May 2018, 3:51 PM
‎ ‏‏‎Anonymous Guy
+ 1
yeah right use * for array
12th May 2018, 3:53 PM
‎ ‏‏‎Anonymous Guy
+ 1
「HAPPY TO HELP」 yes, that's the main issue (sorry if I didn't make it clear)
12th May 2018, 3:56 PM
fallOut015
fallOut015 - avatar
+ 1
or you can modify your code a bit int random = rand() % sizeof(ar)/sizeof(ar[0]); <- this part the bracket
12th May 2018, 4:12 PM
‎ ‏‏‎Anonymous Guy
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
12th May 2018, 3:51 PM
fallOut015
fallOut015 - avatar
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
12th May 2018, 3:53 PM
fallOut015
fallOut015 - avatar
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*
12th May 2018, 3:55 PM
fallOut015
fallOut015 - avatar
12th May 2018, 4:00 PM
fallOut015
fallOut015 - avatar