Mail Archives: djgpp/1997/02/03/16:59:34
Dim Zegebart wrote:
>
> //FOO3
> int foo3(TMyType *ptr)
> {
> //TMyType has fields fld1 and fld2 both int
> int i,fld1=ptr->fld1,fld2=&ptr->fld2;
^
I assume you forgot to take out that address operator...
> for (i=0;i<100000;i++)
> { fld1++; //here may be any expression. ++ just for example
> fld2--;
> }
> ptr->fld1=fld1;
> ptr->fld2=fld2
> return(1);
> }
Sorry; I replied too soon. This last function will not work the way you
want it to. By assigning ptr->fld1 to fld1, you are making a _copy_ of
that field. Then when you modify the copy, the original is unchanged.
This function will probably be faster than the first two (for obvious
reasons), but it won't work. :)
--
---------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com |
| Call me for your free AOL disk! | http://www.cs.com/fighteer |
| Chain letters, work-at-home schemes, free long distance, etc., |
| are ILLEGAL! Keep the Internet litter-free... don't SPAM. |
---------------------------------------------------------------------
- Raw text -