When I run below code in MSVS, compiler gives
"Error 1 error C2059: syntax error : '{'
I am sure I am declaring and initializing double dimensional array right. Where is the syntax error?
#include <stdio.h>
#define STUDENTS 3
#define EXAM 4
void printArray(int array[][EXAM]);
int main(void){
int array[STUDENTS][EXAM];
array={ { 77, 68, 86, 73 },{ 96, 87, 89, 78 },{ 70, 90, 86, 81 } };
You have to declare and initialize the array in a single statement.
int array[STUDENTS][EXAM]={ { 77, 68, 86, 73 },{ 96, 87, 89, 78 },{ 70, 90, 86, 81 } };
If you really need to initialize the array separately from its declaration, then you need to do it the hard way by setting each member individually.
array[0][0] = 77;
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With