What is causing my syntax error?

Hello, whenever I try to call an array in a function, I get a syntax error for my brackets. I'm not sure what I'm doing wrong.

Thanks in advance!

 
  		fcSold = getFCSold(FCTBL[][4], SOLD);
Here's more of the code, to maybe give a better idea.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int getFCSold(int[], int);					//To get the number of Fist Class seats already sold.

//***********************************************************
//				getFCSold									*
//	To get the number of First Class seats already sold.	*
//***********************************************************

int getFCSold(int FCTBL[][4], int SOLD)
{
	int fc = 0;
	int total = 0;

	while (SOLD == 0)
	{
		for (fc = 0; fc < FCSIZE; fc++;)
			total += fc;
	}

	return total;
}
And here is the error I'm receiving:

1>c:\users\beverly\onedrive\school\ciss 241\week8_courseproject\week8_courseproject\source.cpp(84): error C2059: syntax error: ']'
Your prototype on line 1 doesn't match the function implementation on line 8. How is that array actually defined?
Line 1 is my prototype, the first comment is the call (fcSold = getFCSold(FCTBL[][4], SOLD);
) and line 8 is the header.

Is it because I'm missing the second set of brackets?
I get the same error when I add the second set of brackets. I had this same error in my program from last week. I don't understand though, because in my book it shows it this way and states it can be written this way. Maybe I'm too tired to think at this point and it's obvious, but I just don't see it.
So when I've added my first size array, I now have a different error.

 
		fcSold = getFCSold(FCTBL[5][4], SOLD);


ERROR:
1>: error C2664: 'int getFCSold(int [],int)': cannot convert argument 1 from 'int' to 'int []'
1
2
3
4
5
6
7
8
9
10
11
12
13
int getFCSold(int [][4], int);

// ...

int getFCSold(int FCTBL[][4], int SOLD)
{
    // ...
}

    // ...

    fcSold = getFCSold(FCTBL, SOLD);
    // ... 
@beverlyras

When you pass an array to a function the argument for the array should be just the name of the array, not with the brackets.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int arrayFunction(int[]);

int main()
{
    int array[10];

    // no brackets just the name
    arrayFunction(array);

    return 0;
}

int arrayFunction(int array[])
{
    // stuff . . .
}
Last edited on
Thank you!! I knew there was something easy I was missing.
Topic archived. No new replies allowed.