M
Michael Press
Given a pointer, p, can I set pm1 = p-1 and use pm1
without worrying that an implementation will object
or do other than what one expects? The idea is to
get offset one arrays, e.g.,
void
f(int *p, int l)
{
int i;
int t;
int *pm1 = p - 1;
for(i = 1; i <= l; i++)
t = pm1;
}
int a[] = {1, 2, 3};
int na = sizeof a / sizeof *a;
void
doit(void)
{
int *b = a;
f(a, na);
f(b, na);
}
without worrying that an implementation will object
or do other than what one expects? The idea is to
get offset one arrays, e.g.,
void
f(int *p, int l)
{
int i;
int t;
int *pm1 = p - 1;
for(i = 1; i <= l; i++)
t = pm1;
}
int a[] = {1, 2, 3};
int na = sizeof a / sizeof *a;
void
doit(void)
{
int *b = a;
f(a, na);
f(b, na);
}