Computer
Programming
Defining structure
For structure, we use struct keyword.
Syntax:
struct struct_name{ structure_member };
struct address{
unsigned int house_number;
char street_name[50];
int zip_code;
char country[50];
};
Declaring structure
The above example only defines an address structure without create any instance of it. To create or declare a structure you have two ways:
The first way is declare a structure follows by structure definition like this:
struct struct_name {
structure_member;
...
} instance_1,instance_2 instance_n;
In the second way you can declare your structure instance at a different location in your source code after structure definition.
Syntax :
struct struct_name instance_1,instance_2 instance_n;
Complex structure
Structure can contains arrays or other structures so it is sometimes called complex structure.
For example address structure is a complex structure.
struct customer{
char name[50];
structure address billing_addr;
structure address shipping_addr;
};
The reference site for this content is http://cprogramminglanguage.net/c-structure.aspx




