a more advanced data type is the structure


  A more advanced data type is the structure; here we can define a template as a collection of different variables e.g.
 
  struct birthdate
  {
    int month;
    int day;
    int year;
  };
 
  Here the template birthdate consists of three separate content variables namely month   , day , year .We can access each part of the structure by means of the dot '.' operator i.e. after we have allocated the variable to be used to hold the structure.
 
    struct  birthdate john;
 
We can access all the details i.e.
 
      john.month  = 12;
      john.day = 28;
      john.year = 52;
 
This is identical to using a two dimensional array to hold the values
 
      john[0][0]  could hold month
      john[0][1]  could hold day
      john[1][0]  could hold year

However using a structure template we can use different types in the same structure
   
    struct details
    {
    int month;
    int day;
    int year;
    char * name;
    };
 
It is possible to use structures defined as pointers, if you wish to want to use the actual address.
 
  
    main()
    {
      struct *records 
      {
      int month;
      int day;
      int year;
      char * name;
      };
 
  Here we have a structure assigned to a pointer record. In order to access the content month we use must dereference the pointer and access the element i.e.
 
      (*records).month 
 
This is often replaced with a -> symbol (minus followed by >) i.e.
 
      records -> month.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a more advanced data type is the structure
Reference No:- TGS0265294

Expected delivery within 24 Hours