Structures, C/C++ Programming

Assignment Help:

  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.


Related Discussions:- Structures

Pointers, one of the applications of computers in numerical analysis is com...

one of the applications of computers in numerical analysis is computing the area under a curve. one method of calculating the area under acurve is to divide the area int a number o

Program to make another type of mask, Write a function that has int paramet...

Write a function that has int parameter n, makes another type of mask having n bit 1's from the left most bit and 32- n bit 0's next. The mask is called netmask in this seminar, an

Set performance data and print tickets, Create a class  called  ticketSelli...

Create a class  called  ticketSelling that stores booking information of a single performance on a single day and sells the tickets of the performance. The class should include at

Program to draw a circle - c program, Program to draw a circle: int ma...

Program to draw a circle: int main(void) {    /* request auto detection */    int gdriver = DETECT, gmode, errorcode;    int midx, midy;    int radius = 100;

C program for function of average, C program for function  of average ...

C program for function  of average int average(int); void main() {           int max=0,c=0;           clrscr();           printf("ENTER THE LIMIT OF INPUT FOR AV

Assignment, Write a program that computes the cost of a long distance call....

Write a program that computes the cost of a long distance call. The cost of the call is determined according to the following rate schedules. a. A call made between 8:00 AM and

Explain the array types, Array types An array is a collection of object...

Array types An array is a collection of objects of a one data type. The individual objects are accessed by their position in the array. This way of accessing is known as indexi

Function, limitation of function

limitation of function

Program to find a greatest string: c - program , Program to find a Greatest...

Program to find a Greatest String: C - Program: Write a program find largest string by c program. int main( int argc, char *argv[] ) {     if( argc         {

Bankers algorithm, creating a system having five process from p0 to p4 and ...

creating a system having five process from p0 to p4 and five resource types. create the need matrix use the safe algorithm to test if the system is in safe mode.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd