Structures in C Recap
Structures in C Recap
In a Library, each book is an object, and its characteristics like title, author, no of
pages, price are grouped and represented by one record.
The characteristics are different types and grouped under a aggregate variable of
different types.
A record is group of fields and each field represents one characteristic. In C, a record
is implemented with a derived data type called structure. The characteristics of record are
called the members of the structure.
Book-1 Book-2 Book-3
BookID: 1211 BookID: 1212 BookID: 1213
Title : C Primer Plus Title : The ANSI C Programming Title : C By Example
Author : Stephen Prata Author : Dennis Ritchie Author : Greg Perry
Pages : 984 Pages : 214 Pages : 498
Price : Rs. 585.00 Price : Rs. 125.00 Price : Rs. 305.00
membership operator
Implementing a Structure
struct employee {
int empid;
char name[35];
int age; Declaration of Structure Type
float salary;
};
Declaration of Structure variables
int main() {
struct employee emp1,emp2 ; Declaration and initialization of Structure variable