Pointer to Structure

1 / 5

# Pointer to Structure - PowerPoint PPT Presentation

Pointer to Structure. Pointer to Structure. Structure variable can be access using pointers int a=10,*p; Here p is an integer type pointer variable, p can hold the address of an integer(a) ie p=&amp;a; in order to access the content of a  *p

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Pointer to Structure' - acton-bright

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Pointer to Structure
• Structure variable can be access using pointers
• int a=10,*p;
• Here p is an integer type pointer variable,

p can hold the address of an integer(a)

iep=&a;

in order to access the content of a  *p

ie ‘a’ can be access using the pointer variable p

• Like that a structure variable can be access using a pointer variable
Pointer to Structure
• let
• struct student
• {
• char name[20];
• int m1,m2,m3,total
• };

struct student s , *p;

Now ‘s’ is the variable of type struct student

‘p’ is a pointer variable of type struct student

Since p and s are same type, p can store the address of the variable s

Iep=&s;

Now the content of p is address of s

Pointer to Structure
• The structure variable s can be access using p
• With the help of point to operator (->)
• ie
• p->name equalant to s.name
• p->m1 equalant to s.m1
• p->m2 equalant to s.m2
• p->m3 equalant to s.m3
• p->total equalant to s.total
Pointer to Structure
• void main()
• {
• struct check
• {
• int a;
• char c[20];
• };
• struct check s,*p;
• p=&s;
• scanf("%d%s",&p->a,p->c);
• printf("%d %s",p->a,p->c);
• getch();
• }