Structure and union different? BCA 2nd semester


 Structure  Points:-                         

1).keyword struct define a keyword

structure.

2).The size of a structure is the sum of all the members.

3). member of a structure can be initialized at one

4).It supports only assignment=and size of operators.

5). struct name

{

  int val;

 float val;

char *p;

}s;

6). structure each member get separate space in memory.

Union points:-

1). keyword union define a union.

2). The size of a union contain smaller members.

3). union may only initialized with a value.

4).It supports only assignment=and size of operators

5). union name

      {

    int val;

    float val;

   char*p;

   }u;

6). The total special allocated equal to the member with large size.


No comments:

Post a Comment

If you have any doubts, Please lets me know and Please Follow our Website