Subject:
|
Re: IC Pointer Questions
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Sun, 15 Mar 1998 18:54:30 GMT
|
Original-From:
|
Anthony Oren Loeppert <oren@mail.utexas./Spamcake/edu>
|
Viewed:
|
1435 times
|
| |
| |
> struct _wheel {int radius;int ticks;};
> struct _encoder {int port;int *velocity ;int *count;};
> struct drivewheel {struct _encoder encoder;struct _wheel wheel;}
> wheel[4];
>
> wheel[0].encoder.count= &encoder0_counts;
> *wheel[0].encoder.count= 0; /*I want to get rid
> of that dereferencing
> asterix ...*/
>
> Is there a way I can declare "wheel.encoder.count" so that it exists as an
> integer pointing to the same memory location as "encoder0_counts"?
> "wheel[0].encoder.count= 0;" Would then be the same as "encoder0_counts=
> 0;"
If I am understanding you right... I haven't looked at the encoder
routines yet, but I am assuming encoder0_counts is global. Why not, just
omit the pointer count from the _encoder struct and just use the global,
since you already have it? That aside, I'm don't know what you have
against '*' in having the statement *wheel[0].encoder.count = 0; It
accomplishes what you want and that's going to be your only solution I
think. I'm not too familiar with IC, but I am guessing it adhears fairly
closely to standard C in it's implementation. You are wanting to use a
feature of C++, pass by reference. Standard C doesn't support it.
void change_count(int& iamTheSaveVar)
{
iamTheSaveVar=0;
}
int main()
{
int somevar=1;
change_count(somevar);
return somevar;
}
in C++, this would effectively set somevar to 0, but I don't think that it
would work in IC, but I haven't tried it. I would but I am online and I
only have on RS232 serial cable and it is connected to my modem right now
:) The passing by reference is not any different that passing a pointer
and deferencing it.
> Can I change the pointer of an existing integer?
I'm not quite sure what you mean by that.
|
|
Message is in Reply To:
| | IC Pointer Questions
|
| Howdy all, I finally attached an infrared reflectance sensor to my handyboard and it works! With my non-existent electronic experiences I managed to solder a resistance (330 ohms) to a three-legged sensor similar to the four-legged variant mentioned (...) (27 years ago, 15-Mar-98, to lugnet.robotics.handyboard)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|