Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!lethe!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Newsgroups: comp.lang.c Subject: Re: Divide and C Message-ID: <1991Mar28.111154.20309@druid.uucp> Date: 28 Mar 91 11:11:54 GMT References: <1991Mar27.185804.7221@uunet.uu.net> Organization: D'Arcy Cain Consulting, West Hill, Ontario Lines: 26 In article <1991Mar27.185804.7221@uunet.uu.net> Karl Nicholas writes: > EX: int array[10][10]; > val = 24; > ++array[val/10][val%10]; > > This is the only way I know how to do this. > My problem with it is that is requires TWO divides. How about ZERO divides? Use "++array[val];" The following test program works under GCC. #include int main(void) { int a[10][10], *p, v = 24; p = (int *)(a); p[v] = 0x1234; printf("%x\n", a[2][4]); return(0); } -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | There's no government Toronto, Ontario, Canada | like no government! +1 416 424 2871 |