Skip to content

Commit

Permalink
CI run: make.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdoe authored and actions-user committed Aug 9, 2023
1 parent 333da65 commit beb2fd6
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 32 deletions.
65 changes: 49 additions & 16 deletions book.md
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,8 @@ Sometimes material incentives are also very helpful, e.g. a promise 5$ gift card

[day-351 tic tac toe](#day-351-tic-tac-toe)

[day-352 files](#day-352-files)

## [DAY-0] The Computer

All modern computers(laptops, phones, pc master race rgb monsters, etc) have somewhat similar components: Processor, Memory, Video Card, Disk and USB controller, WiFi card etc. Some of them are in one single chip and you cant even see them anymore, but they are there. For example there are chips that have Processor and Video Card together. The term for processor is actually CPU - Central processing unit, but we called it processors when we were kids and it kind of make sense, since it processes stuff.
Expand Down Expand Up @@ -24787,7 +24789,7 @@ int main(void){
.c0 = '-',
.c1 = '-',
.c2 = '-',
};
};

while(1) {
board_print(game_board);
Expand Down Expand Up @@ -24931,7 +24933,7 @@ int main(void) {
*p++;

printf("%d\n",x)

return 0;
}

Expand All @@ -24942,18 +24944,18 @@ int main(void) {
*p = 3;

printf("%d\n",x)

return 0;
}

#include <stdio.h>
int main(void) {
int x = 7;

scanf("%d",&x);

printf("%d\n",x);

return 0;
}
```
Expand Down Expand Up @@ -25110,7 +25112,7 @@ now you can see we can call the function, but we cant go back in order to beep,

```
┌────┬────┬────┬────┐
0 │ 9 │ 15 │ 10 │ 6 │ <- load the value of addr 8 into R1,
0 │ 9 │ 15 │ 10 │ 6 │ <- load the value of addr 8 into R1,
├────┼────┼────┼────┤ so we can go back to wherever it points
4 │ 13 │ 40│ 8 │ 7 │ <- we want to go back to addr 8
├────┼────┼────┼────┤ where we have the beep instruction
Expand Down Expand Up @@ -25165,7 +25167,7 @@ void print_board(char *b) {
}
int check_win(char *b){
if (b[0] != '-' && b[0] == b[1] && b[1] == b[2]) {
return 1;
return 1;
}
if (b[3] != '-' && b[3] == b[4] && b[4] == b[5]) {
return 1;
Expand Down Expand Up @@ -25201,31 +25203,31 @@ int main(void) {
char str[3];
printf("%c>",symbol);
scanf("%2s",str);
if (str[0] == 'a' && str[1] == '1') {
if (str[0] == 'a' && str[1] == '1') {
board[0] = symbol;
}
if (str[0] == 'b' && str[1] == '1') {
if (str[0] == 'b' && str[1] == '1') {
board[3] = symbol;
}
if (str[0] == 'c' && str[1] == '1') {
if (str[0] == 'c' && str[1] == '1') {
board[6] = symbol;
}
if (str[0] == 'a' && str[1] == '2') {
if (str[0] == 'a' && str[1] == '2') {
board[1] = symbol;
}
if (str[0] == 'a' && str[1] == '3') {
if (str[0] == 'a' && str[1] == '3') {
board[2] = symbol;
}
if (str[0] == 'b' && str[1] == '2') {
if (str[0] == 'b' && str[1] == '2') {
board[4] = symbol;
}
if (str[0] == 'b' && str[1] == '3') {
if (str[0] == 'b' && str[1] == '3') {
board[5] = symbol;
}
if (str[0] == 'c' && str[1] == '2') {
if (str[0] == 'c' && str[1] == '2') {
board[7] = symbol;
}
if (str[0] == 'c' && str[1] == '3') {
if (str[0] == 'c' && str[1] == '3') {
board[8] = symbol;
}

Expand All @@ -25244,3 +25246,34 @@ int main(void) {
}
```


## [DAY-352] files

Watch Bro Code's reading and writing files: https://www.youtube.com/watch?v=UqB4EgUxapM and https://www.youtube.com/watch?v=Hzg3kCHJcxI

> the code she wrote

```

#include <stdio.h>

int main() {
FILE *pF = fopen("test.txt","w");

fprintf(pF, "spongebob sqquerpants KIRA AND RYUK");
fclose(pF);
return 0;
}


#include <stdio.h>
int main() {
FILE *pF = fopen("/Users/jack/book/poem.txt","r");
char buffer[255];
while(fgets(buffer,255,pF) != NULL) {
printf("%s", buffer);
}
fclose(pF);
}
```

2 changes: 1 addition & 1 deletion examples/week-047/001.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(void){
.c0 = '-',
.c1 = '-',
.c2 = '-',
};
};

while(1) {
board_print(game_board);
Expand Down
8 changes: 4 additions & 4 deletions examples/week-047/005.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int main(void) {
*p++;

printf("%d\n",x)

return 0;
}

Expand All @@ -16,17 +16,17 @@ int main(void) {
*p = 3;

printf("%d\n",x)

return 0;
}

#include <stdio.h>
int main(void) {
int x = 7;

scanf("%d",&x);

printf("%d\n",x);

return 0;
}
2 changes: 1 addition & 1 deletion examples/week-047/012.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
┌────┬────┬────┬────┐
0 │ 9 │ 15 │ 10 │ 6 │ <- load the value of addr 8 into R1,
0 │ 9 │ 15 │ 10 │ 6 │ <- load the value of addr 8 into R1,
├────┼────┼────┼────┤ so we can go back to wherever it points
4 │ 13 │ 40│ 8 │ 7 │ <- we want to go back to addr 8
├────┼────┼────┼────┤ where we have the beep instruction
Expand Down
20 changes: 10 additions & 10 deletions examples/week-047/013.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void print_board(char *b) {
}
int check_win(char *b){
if (b[0] != '-' && b[0] == b[1] && b[1] == b[2]) {
return 1;
return 1;
}
if (b[3] != '-' && b[3] == b[4] && b[4] == b[5]) {
return 1;
Expand Down Expand Up @@ -43,31 +43,31 @@ int main(void) {
char str[3];
printf("%c>",symbol);
scanf("%2s",str);
if (str[0] == 'a' && str[1] == '1') {
if (str[0] == 'a' && str[1] == '1') {
board[0] = symbol;
}
if (str[0] == 'b' && str[1] == '1') {
if (str[0] == 'b' && str[1] == '1') {
board[3] = symbol;
}
if (str[0] == 'c' && str[1] == '1') {
if (str[0] == 'c' && str[1] == '1') {
board[6] = symbol;
}
if (str[0] == 'a' && str[1] == '2') {
if (str[0] == 'a' && str[1] == '2') {
board[1] = symbol;
}
if (str[0] == 'a' && str[1] == '3') {
if (str[0] == 'a' && str[1] == '3') {
board[2] = symbol;
}
if (str[0] == 'b' && str[1] == '2') {
if (str[0] == 'b' && str[1] == '2') {
board[4] = symbol;
}
if (str[0] == 'b' && str[1] == '3') {
if (str[0] == 'b' && str[1] == '3') {
board[5] = symbol;
}
if (str[0] == 'c' && str[1] == '2') {
if (str[0] == 'c' && str[1] == '2') {
board[7] = symbol;
}
if (str[0] == 'c' && str[1] == '3') {
if (str[0] == 'c' && str[1] == '3') {
board[8] = symbol;
}

Expand Down
21 changes: 21 additions & 0 deletions examples/week-047/014.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#include <stdio.h>

int main() {
FILE *pF = fopen("test.txt","w");

fprintf(pF, "spongebob sqquerpants KIRA AND RYUK");
fclose(pF);
return 0;
}


#include <stdio.h>
int main() {
FILE *pF = fopen("/Users/jack/book/poem.txt","r");
char buffer[255];
while(fgets(buffer,255,pF) != NULL) {
printf("%s", buffer);
}
fclose(pF);
}
2 changes: 2 additions & 0 deletions toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -872,3 +872,5 @@
[day-350 machine code; functions](#day-350-machine-code-functions)

[day-351 tic tac toe](#day-351-tic-tac-toe)

[day-352 files](#day-352-files)

0 comments on commit beb2fd6

Please sign in to comment.