Declaring and Defining Structures
Learn different ways of declaring and defining structures in C.
Declaring and defining structures
Method 1
If the declaration and definition are separate, we cannot drop the structure name.
See the code given below!
Press + to interact
#include<stdio.h>// Method 1: We cannot drop the structure name// Employee declarationstruct employee{char n[ 20 ] ;int a ;float s ;} ;int main() {// Employee definitionstruct employee e = { "Rahul", 25, 4000.50 } ;printf ( "%s %d %f\n", e.n, e.a, e.s) ;}
When we declare the data type, struct
employee, no bytes ...