how to write a structure in c code example
Example 1: C structure
struct struct1 {
int a;
char b;
}
typedef struct struct2 {
int a;
char b;
} name;
void main()
{
struct struct1 var1;
name var2;
var1.a = 10;
var2.b = 'c';
}
Example 2: declare structure in c
struct num{
int a ;
int b;
};
int main()
{
struct num n;
//accessing the elements inside struct
n.a=10;
n.b=20;
}