Addresses and stuff!

I wanted to write a short guide to using pointers and stuff, since I always forget that sort of thing. At least the three first times I “started doing it again”. Like, you go object-oriented for a year and then you’re suddenly thrown back into C and IEC61131-3 (languages for plc-programming (programmable logic controllers, for controlling machines within industrual automation)).

Anyway, it goes faster and faster now.. But I wanted a pedagogic picture also, with arrows and stuff.. maybe I’ll add it later.

C is first:

&myFirstVariable – “address of “, is an unsigned long that is the memory address to the place where myFirstVariable is stored.

*pMyFirstVariable – “on this address”, is whatever pMyFirstVariable is an address to. So pMyFirstVariable is an unsigned long (p is “pointer to”).

Once you mastered these to operators, you can do practically anything you want. And you know about computer memory. Some time maybe I can think of some really confusing examples to go with the above standalone useless information!

Advertisements

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: