Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!nrl-cmf!ukma!gatech!udel!rochester!ur-tut!sunybcs!rutgers!im4u!ut-sally!utah-cs!utah-gr!uplherc!esunix!rushfort From: rushfort@esunix.UUCP (Kevin Rushforth) Newsgroups: comp.lang.c Subject: Re: arrays -> pointers Message-ID: <656@esunix.UUCP> Date: 19 Jan 88 17:56:33 GMT References: <3761@sigi.Colorado.EDU> Organization: Evans & Sutherland, Salt Lake City, Utah Lines: 41 in article <3761@sigi.Colorado.EDU>, swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) says: > > Here is a line of code that I got out of a book: > > (*(mn+hsel-1)->func[vsel-1])(hsel,vsel); Correct, assuming the following typedefs and variables (or some equivalent): typedef void (*funcp)(); typedef struct { funcp *func; } mystruct; mystruct *mn; int vsel,hsel; > With it using arrays in both places that would look normal I think it would > look like this: > > (*ms[hsel-1].func[vsel-1])(hsel,vsel); Also, correct; > ANyway, does anyone know how to get it to that it won't use *any* array > brackets? I tried stuff like: > > (*(*(mn+hsel-1)->func+vsel-1))(hsel,vsel); Not quite. This should be written as: (**((mn+hsel-1)->func+vsel-1))(hsel,vsel); In your example, you try to add (vsel-1) to the pointer (mn+hsel-1)->func AFTER dereferencing it rather than before. Hope this helps. -- Kevin C. Rushforth Evans & Sutherland Computer Corporation UUCP Address: {ihnp4,ucbvax,decvax,allegra}!decwrl!esunix!rushfort Alternate: {bellcore,cbosgd,ulysses}!utah-cs!esunix!rushfort