Is there a way to declare an array in C so the indexing starts at something besides zero? Like if I wanted the array to be a[-10] to a[10] instead of a[0] to a[20]?
Name:
Anonymous2009-01-26 23:42
Why would you want that?
Name:
Anonymous2009-01-26 23:44
I want an array that holds a number for each point in a 2D grid, but I want the origin (point (0,0)) to be in the middle, so I want to use negative indicies.
n/m though, I figured out how to do it with a #define.
Name:
Anonymous2009-01-26 23:47
I want an array that holds a number for each point in a 2D grid, but I want the origin (point (0,0)) to be in the middle, so I want to use negative indicies.
n/m though, I figured out how to do it with a #define.
>>8-9
Valid but a hash map is slower and takes a good deal more memory than a true array.
#define for negative indexed array Go back to www.dailywtf.com,please.
Name:
Anonymous2009-01-27 6:16
Just do something like this: int a[20];
int *p = &a[10];
p[-10] = 0;
Name:
Anonymous2009-01-27 6:20
>>4 I want an array that holds a number for each point in a 2D grid, but I want the origin (point (0,0)) to be in the middle, so I want to use negative indicies.
No, you don't.