Main Menu
Home
AVR News
Atmel AVR
AVR Development Tools
Valuable Tools
WinAVR toolset
Makefile for WinAVR
AVR Virtual Simulators
Hardware for prototyping
GCC and AVR-GCC
Short introduction to C
AVR-GCC Tutorial
Example AVR Projects
AVR-GCC articles
WinAVR Site Map
Scienceprog FORUM
ScienceProg BLOG
Disclaimer
WinARM Tutorial
Latest comments
Measuring motor speed and...
Dear Administrator The code above...
More...

Programming AVR ADC module...
hi please send me example usart with...
More...

Measuring motor speed and...
main.c: In function...
More...

Running TX433 and RX433 RF...
(Hopefully this is not a re-post). I am...
More...

Running TX433 and RX433 RF...
I just bnought a pair of the RX/TX 433...
More...

Friendly sites

Related Items:

Recommended sites


Pointers to structures in embedded C PDF Print E-mail
Written by Administrator   
Tuesday, 05 September 2006

Sometimes you might like to manipulate the members of structures in more generalized way. This can be done by using pointer reference to structure. Sometimes it is easier to pass pointer to structure than passing entire structure to function.

Structure pointer can be declared very easily:

struct structure_tag_name *variable;

For instance:

struct position{
	int x;
	int y;
}pos1, *pos2;

we can assign first structure address to structure pointer like this:

pos2=&pos1;

now we can access first structure members by using structure pointer:

pos2->x=10;

or we can write

(*pos2).x=10;

Structures can contain member pointers to other structures or to structures of same tyme. This way we can create lists – dynamic structure:

struct list{
	int listNo;
	struct list *next;	//pointer to another structure
}item1, item2;

This way you can assign the pointer with address to another structure:

item1.next=&item2;

Read more about dynamic structures in C tutorials.


Related Items:

   

Users' Comments  
 

Average user rating

 


Add your comment
Only registered users can comment an article. Please login or register.

No comment posted



mXcomment 1.0.6 © 2007-2008 - visualclinic.fr
License Creative Commons - Some rights reserved
< Prev   Next >

© 2008 WinAVR AVR-GCC Tutorial
Joomla! is Free Software released under the GNU/GPL License.