C – Pointers and Structures

C – Pointers and Structures 2017-08-07T14:15:54+00:00

Pointers and Structures :

A pointer can also point to a structure.

Example :

struct student

{

            int sno;

char sname[20], course[20];

float fee;

  };

 

    struct student s;

struct student *p;

Here p is defined to be a pointer, pointing to student structure,

we can write

p = &s;

After making such an assignment we can access every data item of student  structure through  p .

è(Arrow)

————–

-> is the combination of  –  followed by  > .

It is used to access the data items of a structure with the help of structure pointer.

syntax:

Struct_pointer  -> data item;

 

Eg:

pà sno;

pà sname;

pà course;

pà fee;

C – POINTERS AND STRUCTURE EXAMPLE PROGRAM :

 

Prev Next