definition of multi-dimensional array failure

Hi all.

I have a 4 dimensional array declared as such as global:

 
char OurShapes[7][4][4][2];


And it's defined here:
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

void fillshapes()
{
	OurShapes = 
	{
		//line
		{
			//rotation1
			{
				{0, 0},
				{0, 1},
				{0, 2},
				{0, -1}
			},
			//rotation2
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{2, 0}
			},
			//rotation3
			{
				{0, 0},
				{0, 1},
				{0, 2},
				{0, -1}
			},
			// rotation4
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{2, 0}
			}
		},
		// square
		{
			//rotation1
			{
				{0, 0},
				{1, 0},
				{0, -1},
				{-1, -1}
			},
			//rotation2
			{
				{0, 0},
				{1, 0},
				{0, -1},
				{-1, -1}
			},
			//rotation3
			{
				{0, 0},
				{1, 0},
				{0, -1},
				{-1, -1}
			},
			//rotation4
			{
				{0, 0},
				{1, 0},
				{0, -1},
				{-1, -1}
			}
		},
		// S
		{
			//rotation1
			{
				{0, 0},
				{0, 1},
				{1, 1},
				{-1, 0},
			},
			//rotation2
			{
				{0, 0},
				{-1, 0},
				{-1, 1},
				{0, -1}
			},
			//rotation3
			{
				{0, 0},
				{0, 1},
				{1, 1},
				{-1, 0},
			},
			//rotation4
			{
				{0, 0},
				{-1, 0},
				{-1, 1},
				{0, -1}
			}
		},
		// S reversed
		{
			//rotation1
			{
				{0, 0},
				{1, 0},
				{0, 1},
				{-1, 1}
			},
			//rotation2
			{
				{0, 0},
				{0, -1},
				{1, 0},
				{1, 1}
			},
			//rotation3
			{
				{0, 0},
				{0, 1},
				{0, 1},
				{-1, 1}
			},
			//rotation4
			{
				{0, 0},
				{0, -1},
				{1, 0},
				{1, 1}
			}
		},
		// L
		{
			//rotation1
			{
				{0, 0},
				{0, 1},
				{0, -1},
				{1, -1}
			},
			//rotation2
			{
				{0, 0},
				{1, 0},
				{-1, 0},
				{-1, -1}
			},
			//rotation3
			{
				{0, 0},
				{0, -1},
				{0, 1},
				{-1, 1}
			},
			//rotation4
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{1, -1}
			}
		},
		// L reversed
		{
			//rotation1
			{
				{0, 0},
				{0, 1},
				{0, -1},
				{-1, -1}
			},
			//rotation2
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{-1, 1}
			},
			//rotation3
			{
				{0, 0},
				{0, -1},
				{0, 1},
				{1, 1}
			},
			//rotation4
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{1, -1}
			}
		},
		// T
		{
			//rotation1
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{0, 1}
			},
			//rotation2
			{
				{0, 0},
				{0, 1},
				{1, 0},
				{0, -1}
			},
			//rotation3
			{
				{0, 0},
				{-1, 0},
				{1, 0},
				{0, -1}
			},
			//rotation4
			{
				{0, 0},
				{-1, 0},
				{0, -1},
				{0, 1}
			}
		}
	};
}


Yet for some reason I get the following error:

Error C2059: Syntax Error : '{'


This error corresponds to the first curly bracket ({) after the line OurShapes =

Any ideas?

FYI After that error I have another 99 all to do with this 4D array definition. I can't for the life of me work out what's wrong... any idead?

Mike

P.S. I got a simlar array to work before - but lost the code... :(

Any ideas what I've done?
You're missing the variable name. It shoudl be:
 
OurShapes shapes = 
Afraid that doesn't work...

That just produces the error:
 
error C2146: syntax error : missing ';' before identifier 'shapes'


Besides I'm not declaring a variable type... just the variable itself - Or at leasth I think I am...

Thank you though kbw - at least someone's looking into it with me lol
Mike
Last edited on
Okay, here's an up date:

I've removed the global declaration, and simply declared it in the function it's being defined in.

Example:
1
2
3
4
void fillshapes()
{
     char OurShapes[7][4][4][2] = 
     {  etc.


Problem with this is the array must be global - as soon as this function ends the array falls out of scope and is destroyed. Also for some reason it won't compile even like this without the subscripts informing the compiler how big it is ( char OurShapes[][][][] = ) despite the fact that I was under the impression that Microsoft Visual Studio can work that part out for itself...

Anyway I still have the problem that even if I define the array with a set size for each dimension of the array it still is not global.

How can I overcome this? Can I make a locally declared 4D Array global?

Mike
Sorry, silly mistake. It should be:
 
char OurShapes[7][4][4][2] =
You can not assign values to an array as you were doing in the first your code snip. You may do thiis only then the array is declared that is initialization of an array is allowed only when it is declared.
If you want that it would have new values in a function then you assign values to each element of bthe array in the loop. You may not use the syntax of initialization of array.
Topic archived. No new replies allowed.