Loading....
Coupon Accepted Successfully!

 

Referencing Structure Elements

  • Accessing the data from a particular structure is very simple.

  • To access the structure element, the operator used is the dot (.).

  • The general format is

Structure_name. variable name;

Where
structure name - gives the name of the structure
variable name - the element inside the structure
  • For example

struct date
{
long date;
String day;
long month;
}
Date_of_birth;

Above is the simple structure; to access the variable see the following

Date_of_birth.date;

Date_of_birth.day;

Date_of_birth.month;

Initializing Structure elements

  • Initializing the structure element is nothing but assigning values to the accessed variable.
  • For example

Date_of_birth.date=15;
Date_of_birth.day = "Tuesday";
Date_of_birth.month=2009;

  • So that for every structure element is provided a element.
Note: If a structure has to be used for generating multiple variable , then multiple structure elements can be created.




Test Your Skills Now!
Take a Quiz now
Reviewer Name