Download presentation
Presentation is loading. Please wait.
Published byMilo Batchelor Modified over 9 years ago
1
Pointer to Structure
2
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=&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
3
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 Ie p=&s; Now the content of p is address of s
4
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
5
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(); }
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.