Pointer Within Structure in C Programming :
- Structure may contain the Pointer variable as member.
- Pointers are used to store the address of memory location.
- They can be de-referenced by '*' operator.
struct Sample { int *ptr; //Stores address of integer Variable char *name; //Stores address of Character String }s1;
- s1 is structure variable which is used to access the "structure members".
s1.ptr = # s1.name = "Pritesh"
- Here num is any variable but it's address is stored in the Structure member ptr (Pointer to Integer)
- Similarly Starting address of the String "Pritesh" is stored in structure variable name(Pointer to Character array)
- Whenever we need to print the content of variable num , we are dereferancing the pointer variable num.
printf("Content of Num : %d ",*s1.ptr); printf("Name : %s",s1.name);


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