Hey all. I’m working on a small C++ console based game in which I’m a little stuck on.
I am trying to pass the value of a variable into an array which is an argument of a function.
Let me explain. The player is able to make choices by either inputting 1, 2, or 3 which is stored in int playerChoice;
. Once the player makes their choice, I am wanting the current value of playerChoice
to go into an array which is defined as follows int StorePlayerChoices(int *playerchoices, int size)
. This function will then iterate over the array, print out each value as they are added to each element (up to 10), then perform some maths.
Currently, when I attempt to print out the array, it’s filled with random numbers (probably because it’s not initialised correctly), or it only states there is only one element when there should be 10.
Does anyone have any potential solutions for this? Also, sorry if I have explained this poorly.