error: expected primary-expression before ']' token

I'm getting an error while compiling my program. Any suggestion please.
I'm getting "error: expected primary-expression before ']' token" in lines 13 and 20.

1 #include <iostream>
2 #include <iomanip>
3 using namespace std;
4
5 void Function( const int [][4]);
6
7 void print_entering( const int a[5][4])
8 {
9
10 for ( int i=0; i<5; i++ )
11 {
12 for ( int j=0; j<4; j++ )
13 cin>> a[][j];
14 }
15
16
17 for ( int k=0; k<5; k++ )
18 {
19 for ( int m=0; m<4; m++ )
20 cout<< a[][m];
21 cout<<endl;
22 }
23 }
24
25
26 int main()
27 {
28 int university1[5][4]={};
29
30 print_entering(university1);
31
32 return 0;
33 }
You shall specify indexes for an accessed array element. So this statement

cin>> a[][j];

is invalid because the compiler does not know which element of the array to use. I think you meant

cin>> a[ i ][j];

The same is valid for the another statement in your code
I did it but still reporting errors.

the errors are:

line 13 error: ambiguous overload for 'operator>>' in 'std::cin >> *((((((unsigned int)i) * 4) + ((unsigned int)j)) * 4u) + ((const int*)a))'
line 20 : error: using obsolete binding at `i'
You can not change an array which defined with qualifier const

void print_entering( const int a[5][4])
Last edited on
Okay I'll change that. Thank you so much :)
Topic archived. No new replies allowed.