Share on Google+Share on Google+

C Structure Pointer

This section illustrates you the concept of Structure Pointer in C.

C Structure Pointer


This section illustrates you the concept of Structure Pointer in C. You can see in the given example, we want to access the employee's information through structure pointer. For that, we declare the structure type st consisting of members id, name and address. Then we have declared a structure pointer as:

struct st employee, *stptr;

We point the pointer to employee with the expression stptr = &employee. Then access the given members by de-referencing the pointer. For this, we have used another structure selection operator which works on pointers to structures. If p is a pointer to a structure and m is a member of that structure, then p->m. We set the values of specified members as:

stptr->id = 1;
stptr->name = "Angelina";
stptr->address ="Rohini,Delhi";

Here is the code:


#include <stdio.h>
#include <conio.h>

int main() {
  struct st {
  int id;
  char *name;
  char *address;
  struct st employee, *stptr;
  stptr = &employee;
  stptr->id = 1;
  stptr->name = "Angelina";
  stptr->address ="Rohini,Delhi";
  printf("Employee Information: id=%d\n%s\n%s\n", stptr->id, stptr->name,
  return 0;

Output will be displayed as:


Download Source Code:



Posted on: February 6, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: C Structure Pointer   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
August 29, 2012
thanks.. for C tutorial

Hi, not many people share their knowledge or help others for free. thanks for for ur help in posting such tutorial. keep up this effort.. with regards, pekon