Hi. Simple quesiton, I think: I'm trying to initialize an array of structures, each with an integer and 4 integer pointers. I have written the following:
The compiler gives me the following error:Code:main(){ struct lattice_site{ int spin; int *right_pointer; int *left_pointer; int *up_pointer; int *down_pointer; }; struct lattice_site mc_array[2]; mc_array[0] = {1,0,0,0,0}; return 0; }
structure_tester.c: In function `main':
structure_tester.c:15: parse error before '{' token
line 15 refers to the line " mc_array[0] = {1,0,0,0,0}; "
What confuses me is that this syntax works when you aren't using an array of pointers. That is, if I replace mc_array[i] with mc_array in both places, it initializes just fine.
I really need to make a 2-dimensional array of structures like the one above. Will this work?
Thanks!