Differences between structures and arrays - C
Point
|
Array
|
Structure
|
Data
Collection
|
Array
is a collection of homogeneous data.
|
Stucture
is a collection of heterogeneous data.
|
Element
Reference
|
Array
elements are referred by subscript.
|
Structure
elements are referred by its unique name.
|
Access Method
|
Array
elements are accessed by it's position or subscript.
|
Stucture
elements are accessed by its object as '.' operator.
|
Data
Type
|
Array
is a derived data type.
|
Structure
is user defined data type.
|
Syntax
|
<data_type>array_name[size];
|
structstruct_name
{
structure
element 1;
structure
element 2;
----------
----------
structure
element n;
}struct_var_nm;
|
Example
|
intrno[5];
|
structitem_mst
{
intrno;
char
nm[50];
}it;
|
0 comments:
Post a Comment