Elaborating struct comparison (#22429)

* Elaborating struct comparison

* fix: corrected path name issues
This commit is contained in:
raghavbhartia
2018-11-15 04:22:11 +05:30
committed by Randell Dawson
parent 86accd2bd2
commit ee8feba4b5

View File

@ -53,7 +53,8 @@ point img_dim = { .y = 480, .x = 640 };
``` ```
## Unions vs Structures ## Unions vs Structures
Unions are declared in the same way as structs, but are different because only one item within the union can be used at any time.
Unions are declared in the same was as structs, but are different because only one item within the union can be used at any time.
```C ```C
typedef union{ typedef union{
@ -83,6 +84,7 @@ typedef union{
``` ```
## A few more tricks ## A few more tricks
* When you create a pointer to a structure using the `&` operator you can use the special `->` infix operator to deference it. This is used for example when working with linked lists in C * When you create a pointer to a structure using the `&` operator you can use the special `->` infix operator to deference it. This is used for example when working with linked lists in C
* The new defined type can be used just as other basic types for almost everything. Try for example to create an array of type `student` and see how it works. * The new defined type can be used just as other basic types for almost everything. Try for example to create an array of type `student` and see how it works.
* Structs can be copied or assigned but you can not compare them! * Structs can be copied or assigned but you can not compare them!