EmbLogic's Blog

structure.

structure- we can say that it is user defined array but it contains diff data types in a continuous memory location.
syntax-
struct name — user defined data type
{
type1 element1;
type2 element2;

};
struct name variable; –to allocate space
To access elements
there are two methods to access elements
a.) when structure variable is used.
an operator scope resolution operator( . ) is used.
variable.element;
b.) when structure pointer is used.
first of all we must allocate memory to the pointer which can be done by using malloc.
But typecasting is reqired.
pointer name = (struct name *)malloc(sizeof(struct name));
( struct name *) is used for type casting.
operator (->) is used to access elements.
pointer->element;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>