Tag Archives: C struct

C struct

In C programming struct is a structured (record type) that creates a collection of different type of variable under a single name. If we want to store record of student. We can store name , rollno, phone no , address etc. using one variable, then struct makes it possible.

Syntax of struct in c :

struct  tag_name {

type attribute;

type attribute;

/ * ……. */


For example to store info of student :

Declaration of stu_info :

Accessing attributes:

Accessing attribute rollno;

rollno can be accessed by s1.rollno;

similiary other varibles also can be accessed.

Pointer to the struct:



Array of structure :

We have seen array of int , float , char .Similarly array of struct can also be defined. This is used to store students info , customer info etc..