Primary Expression Error When Passing An Array Through Parameters To Another Function

I'm making a proof of concept program for what will basically be a base model for shops in a game I plan to make. I ran into an issue when I attempted to pass an array that holds the quantity of items the player own. However, doing so caused an error that states: "expected primary-expression before ']' token". This is found in lines 16 and 17. These lines are where I call the functions in the main function. Upon attempting to research this issue, I would only get solutions for instances of this error when there are simple syntax errors(i.e. a semi colon misplaced after a '}').

The code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <string>
#include <cstdlib> //This library is needed to prevent a compiler error with Code Blocks when system("PAUSE"); is used.
using namespace std;

void shopPrototype_stuff();
void shopPrototype_pinv(int pInv[]);
void shopPrototype_buy(int pInv[]);
bool shopPrototype_return(bool isPlaying);

int main(){
        int pInv[3] = { }; //Player inventory is stored in an array. Will be changed to list duplicates as a "stack"
    bool isPlaying; //variables that checks if the player wants to continue shopping
    while(isPlaying == true){ //code is run continuously until the player specifies not to.
    shopPrototype_stuff();
    shopPrototype_buy(pInv[]); //error caused by a supposed need for a primary expression
    shopPrototype_pinv(pInv[]); //same error as the previous line
    shopPrototype_return(isPlaying);} //function to determine whether or not to continue the loop
system("pause"); //prevents the program from terminating early
return 0;}

void shopPrototype_stuff(){ //this prints the items in the shop
        string item[3] = {"A rock...just a rock.", "OP Gun of Noobness", "Bass Cannon"};
                cout<<"Welcome to the shop!\nHere is what we have in stock:"<<endl;
    for(int i = 0; i < 3; i++){
                cout<<i +1<<") "<<item[i]<<endl;}
                cout<<endl;}

void shopPrototype_pinv(int pInv[]){
                cout<<"===== Your Inventory ====="<<endl<<endl;
    for(int j = 0; j < 3; j++){ //function prints the values in the array as the player's inventory
                cout<<j + 1<<") "<<pInv[j]<<endl;}
}

void shopPrototype_buy(int pInv[]){ //select an item to buy by typing the number
        int buy;
            cin>> buy;
    switch(buy){ //switch statement to determine purchase
case 1:
        pInv[0] += 1;
    break;
case 2:
        pInv[1] += 1;
    break;
case 3:
        pInv[2]++; //incriment operator was used here to test if both methods actually work. I'm pretty sure they do.
    break;
default: //impromtu check for invalid input
                cout<<"Invalid input"<<endl;
    break;}
}

bool shopPrototype_return(bool isPlaying){ /*asks the player if they want to play again and either continues the loop
    or ends the program by exiting the loop.*/
        string play; //string used instead of chars to hastily alieviate errors with comparison
                cout<<"Would you like to keep shopping?\n Y/N"<<endl<<endl;
            cin>> play;
    if(play == "Y" || play == "y"){
        isPlaying = true;
return isPlaying;}else if(play == "N" || play == "n"){
        isPlaying = false;
return isPlaying;}else{ //will eventually prompt the player with the question again
                cout<<"Invalid input"<<endl;}
}
Just pass pInv. x[] is not a valid expression.

Also, get rid of all those 3s. If the array is of a fixed size, use a constant.
This resolved the issue. Thanks for the advice, I greatly appreciate it. I was aware of the possibility of using a constant instead of merely typing the length in each one manually, but decided to revise that once the error was resolved.
Topic archived. No new replies allowed.