swarbric@tramp.Colorado.EDU (SWARBRICK FRANCIS JOHN) (01/10/88)
Here is a line of code that I got out of a book:
(*(mn+hsel-1)->func[vsel-1])(hsel,vsel);
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);
I haven't actually ran it, but in Turbo C with ALL warning checkers this
compiles (except it gives me a no func. prototype warning, but I don't think
you can get rid of that.)
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);
but that's not it. ANy ideas? It's not like I can't use it the other way,
but it's just to satisfy my curiosity.
------------------------------------------------------------------
Frank Swarbrick | "Ignorance and prejudice --
swarbric@tramp.UUCP | And fear walk and in hand."
swarbric@tramp.Colorado.EDU | --RUSH
...!{hao|nbires}!boulder!tramp!swarbricrushfort@esunix.UUCP (Kevin Rushforth) (01/20/88)
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