Pointer Within Structure in C Programming :

  1. Structure may contain the Pointer variable as member.
  2. Pointers are used to store the address of memory location.
  3. They can be de-referenced by '*' operator.
Example :
struct Sample
{
   int  *ptr;  //Stores address of integer Variable 
   char *name; //Stores address of Character String
}s1;
  1. s1 is structure variable which is used to access the "structure members".
s1.ptr  = #  
s1.name = "Pritesh"
  1. Here num is any variable but it's address is stored in the Structure member ptr (Pointer to Integer)
  2. Similarly Starting address of the String "Pritesh" is stored in structure variable name(Pointer to Character array)
  3. 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);




    Bookmark & Share


    Tags / Keywords : | , , ,

    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