#: 3237 S10/Tandy CoCo
03-May-90 06:20:29
Sb: #3233-#C arrays
Fm: Mark Griffith 76070,41
To: Bob van der Poel 76510,2203 (X)
Bob,
Let's flog the horse once more:
Your initial code had the array delcaration in the function as:
int foo[20][6];
which will not work. The compiler does just what you told it to do, point to
an array of pointers, each pointer of size 2 and 20, so you got 40 memory
locations between each element in the array.
int foo[2][6];
will work since you are now telling the compiler the actual size of the column
element in the array, i.e. 2 bytes (the same as an int pointer).
int foo[][6];
SHOULD work, I didn't try it. Come to think some more, it probably doesn't
work since out compiler is not real smart when it comes to things like this. We
need to tell it what the array looks like.
The very best method is:
int (*foo)[6];
since this is portable across any machine, even those with different size
int's.
Mark
There are 2 Replies.
|