vault backup: 2022-09-05 10:04:46

This commit is contained in:
Jet Hughes 2022-09-05 10:04:46 +12:00
parent 1c4a02c83c
commit d45d5ae14c
3 changed files with 51 additions and 4 deletions

View File

@ -3,6 +3,10 @@ title: "11-struct-and-union"
aliases:
tags:
- cosc204
- lecture
sr-due: 2022-09-08
sr-interval: 3
sr-ease: 250
---
# Struct
@ -54,8 +58,8 @@ location.y = 1;
copy the members including pointers
- but not the things the pointers point to
![shallow copy example 1](https://i.imgur.com/w3B3ce0.png)
![shallow copy example 2](https://i.imgur.com/mL5QION.png)
![shallow copy example 1|200](https://i.imgur.com/w3B3ce0.png)
![shallow copy example 2|400](https://i.imgur.com/mL5QION.png)
both point to the same memory location.
when you change one - they both change.
@ -128,7 +132,39 @@ queue *queue_new(void){
```
enqueue
![enqueue code|400](https://i.imgur.com/suaKfi9.png)
dequeue
![dequeue code|400](https://i.imgur.com/u3mKX5R.png)
# Structs as view
```
typedef struct q_item {
int value; //4-byte integer
struct q_item *next; //8-byte pointer
} queue_item;
```
![](https://i.imgur.com/ObfIzew.png)
struct is a view where the members are laid out consecutively
# Union
multiple views of the same memory
- each line in the declaration is a different view
```
typedef union {
struct {
uint8_t a, b, c, d;
};
uint32_t integer;
} two_views;
```
![diagram|100](https://i.imgur.com/qL8KnW5.png)
## endianess
big-endian vs little-endian
some computer store the most significatn byte first, other store the least significant byte first

View File

@ -0,0 +1,10 @@
---
title: "12-pointers-to-routines"
aliases:
tags:
- cosc204
- lecture
---
# compiler
converts high level language description of program into machine code description of the program

View File

@ -38,7 +38,8 @@ tags:
- [06-6809-programming](notes/06-6809-programming.md)
- [07-6809-advanced](notes/07-6809-advanced.md)
- [08-intro-to-c](notes/08-intro-to-c.md)
-
- [11-struct-and-union](notes/11-struct-and-union.md)
# Archive
# Info