Structure in c++

In some programming contexts, you need to access multiple data types under a single name for easier data manipulation; for example you want to refer to address with multiple data like house number, street, zip code, country. C supports structure which allows you to wrap one or more variables with different data types. A structure can contain any valid data types like int, char, float even arrays or even other structures. Each variable in structure is called a structure member. 

Defining Structure

struct address

int house_number; 

char street_name[50];

int zip_code; 

char country[50]; 

}; 

Declaration of Structure

struct struct_name 

{

structure_member;

...

} ins1,ins2, insn;

Or 

struct struct_name ins1,ins2, insn;

Example:-

#include

struct struct_name 

{

int i;

char a[10];

} ins1,ins2, insn;

void main()

{

ins1.i=10;

strcpy(ins1.a, "Hello");

ins2.i=5;

strcpy(ins2.a, "Hello1");

}

Here in the above example we create 3 object (ins1,ins2,insn) and store data in 2 (ins1 and ins2).

You may also like

What is PHP?

PHP stands for PHP: Hypertext pre-processor, with that PHP standi...

What is ASP.NET?

ASP.NET, the next version of ASP, is a programming framework used...

What is Data Structure?

A data structure is a group of data elements grouped together und...

What is C#?

C# removes some of the complexities and pitfalls of languages suc...

What is Math?

Math is no Definition it has only Calculation.Closure Property of...

What is Oracle?

Based in Redwood, California, Oracle Corporation is the largest s...

Function in java

A function in Java language is a block of code that performs a sp...

Do-While Loop in java

The do-while loop looks like this:do{ this ; and this ; and this ...