summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorloshprung <lshprung@scu.edu>2020-01-15 11:36:18 -0800
committerloshprung <lshprung@scu.edu>2020-01-15 11:36:18 -0800
commit7d3749d0141f62c0beda8284d74c84330ef04d72 (patch)
tree5674773abab356df7c13183155cb899d4ea242a2
parent5c01ce58cb53df8a5cccd0b18b98f2135c191a29 (diff)
Post-class 01/15
-rw-r--r--01-15.md83
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;
+};
+```
+