mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 06:44:07 -06:00
vault backup: 2022-09-05 10:04:46
This commit is contained in:
parent
1c4a02c83c
commit
d45d5ae14c
@ -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
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
both point to the same memory location.
|
||||
when you change one - they both change.
|
||||
@ -128,7 +132,39 @@ queue *queue_new(void){
|
||||
```
|
||||
|
||||
enqueue
|
||||
|
||||

|
||||
|
||||
dequeue
|
||||

|
||||
|
||||
# Structs as view
|
||||
```
|
||||
typedef struct q_item {
|
||||
int value; //4-byte integer
|
||||
struct q_item *next; //8-byte pointer
|
||||
} queue_item;
|
||||
```
|
||||
|
||||

|
||||
|
||||
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;
|
||||
```
|
||||
|
||||

|
||||
|
||||
## endianess
|
||||
big-endian vs little-endian
|
||||
some computer store the most significatn byte first, other store the least significant byte first
|
||||
|
||||
|
||||
10
content/notes/12-pointers-to-routines.md
Normal file
10
content/notes/12-pointers-to-routines.md
Normal 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
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user