Pointer to Structure in C Programming
- Address of Pointer variable can be obtained using '&' operator.
- Address of such Structure can be assigned to the Pointer variable .
- Pointer Variable which stores the address of Structure must be declared as Pointer to Structure .
struct student_database
{
char name[10]
int roll;
int marks;
}stud1;
struct student_database *ptr;
ptr = &stud1;
Way 1 : Using Structure Name
Accessing Roll Number : stud1.roll Accessing Name : stud1.name
Way 2 : Using Indirection Operator and Pointer
Accessing Roll Number : (*ptr).roll Accessing Name : (*ptr).name
Way 3 : Using Membership Operator
Accessing Roll Number : ptr->roll; Accessing Name : ptr->name;
Bookmark & Share


0 comments
Post a Comment
Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email