Skip to main content

Syntax of structure

struct <struct-name> 
{
 <data_type> <data_member1>; <data_type> <data_member2>; ... 
} ; 

 Declaration of a structure:
 
 struct StudentInfo 
 {
  int Rno; 
 char Sname[20];
 };
 
 float percentage;

Here struct is a keyword, 
StudentInfo is a name of structure which is group of elements of different data types like int, string and float. Rno, Sname and Percentage are members of structure StudentInfo enclosed in { }, structure declaration ends with semi-colon (;). 
 Declaration of structure does not reserve any memory space .


Comments