Structure:
-
It is a
user defined data type which provides a unit or block in which more than one
variable of different data type can be kept together.
All the element of structure is loaded in
memory only when the structure type variable is created.
There are two way of creating structural
variable:-
1.
At the time of structure creation.
Since the
structure name is used as data type and since this name is given by user
therefore structure is called as user defined data type.
The entire structural variable occupies separate memory area but shares the same properties and they can be used for separate purpose.
Array
and Structure: -
The relation between array and structure can
be used in two ways.
1.
Array with structure :- In
this case each element of structure is created as array, rather than creating
structural variable as array type.
2.
Array of structure :- In
this case we have to create structural variable as array type, rather than
creating each element as array type.
Structure and
function: -
There are two types of relation can be
establish between structure and function.
1.
Structure as a function argument :- Like
simple variable and array, a function can be accept structure type data also,
in this case we need to declare the structure type variable as function
argument and simply specify the structure variable name as actual argument at
the time of calling.
2.
Function returning structure :- A
function can return structure type variable also. In this case we have to
specify the structure name as returning type in function prototype.
Structure and
pointer: -
Like simple variables and array, a complete
structure can also be managed by pointer.
In this case we need to create structural variable as pointer type and assigned an address of simple structural variable into structural pointer.
In this case we need to create structural variable as pointer type and assigned an address of simple structural variable into structural pointer.
Union:
-
It is also a user
define data type which provides a unit or block in which heterogeneous types of
data can be kept together.
Like structure, the element of union are also
loaded within union type variable area so we need to create union type
variable.
There are two ways of creating union type
variable first one is at the time of union creation and the other one is within any function.
The basic difference between structure and
union is that the element of structure occupies separate memory space within
structural variable area whereas the elements of union share the same space
within union type variable area.
for detailed information download PDF
downloading servers are below
server 1 [media fire]
No comments:
Post a Comment