do*******@o2.pl wrote:
Is it possible to change the address of one element of int table?
My program would be much simpler, if the first element of the table
would be same as last one. I mean:
int *s;
s=(*int)malloc(sizeof(int)*10);
You mean `(int*)', and it would be even better to leave
it out altogether.
…..
and no mater what I would do to this table I want s[0]==s[9] to be
true.
How to do this?
There's no direct way: s[0] and s[9] are separate objects
and are able to hold different values. You'll need to exercise
some discipline of your own, such as
1) Whenever you store to either of them, store to the other
as well.
2) Instead of accessing s[i], access s[i % 9] (you can make
the array one place smaller in this case).
3) Don't access the elements of s[] directly, but always
through an array of pointers `int *sp[10]' which has
been initialized so sp[0] = &s[0], sp[1] = &sp[1], ...,
sp[8] = &s[8], sp[9] = &s[0 /* not 9 */].
--
Eric Sosman
es*****@ieee-dot-org.invalid