diff options
-rw-r--r-- | 01-15.md | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/01-15.md b/01-15.md new file mode 100644 index 0000000..bf362d1 --- /dev/null +++ b/01-15.md @@ -0,0 +1,83 @@ +[\<- Notes 01/13](01-13.md) + +--- + +Notes 01/15/2020 + +# Review Pointers + +Below is an example to demonstrate pointer precedence: + +``` +int x[] = {0, 5, 10, 15, 20, 25, ...}; +int y = 5; +int *p = x; + +y = ++*p +printf("%d, %d\n", y, *p); +y = *(++p); +printf(...); //ditto +y = ++(*p); +printf(...); //ditto +``` + +The code outputs the following: + +``` +1, 1 +5, 5 +6, 6 +``` +--- + +# Introduction to Structures in C + +-`Earlier we talked about data types: int, char +- A Structure allows for multiple data types in one array +- Structure Basics + - A structure is a collection of values, called members + +- Outline of Structure Definition: + +``` +struct name{ + variable declaration; + variable declaration; + ... +}; +``` + +- Example: + +``` +struct info{ + int number; + char character; + char string[10]; + int array[10]; +}; +``` + +- Let's see the memory: + +| | | +| - | - | +| | | +| Real_Info | 55 bytes of storage | +| | | + +- You can also create pointers to data structures + +- Defines a structure type + +--- + +- Another Example: + +``` +struct node{ + int number; + struct node *link; +}; +``` + |