What is a structure?
A structure is a user defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type.
How to create a structure?
‘struct’ keyword is used to create a structure. Following is an example.
struct address
{
char name[50];
char street[100];
char city[50];
char state[20];
int pin;
};
How to declare structure variables?
A structure variable can either be declared with structure declaration or as a separate declaration like basic types.
struct Point
{
int x, y;
} p1;
struct Point
{
int x, y;
};
int main()
{
struct Point p1;
}