Skip to content

Commit d71a468

Browse files
committed
More work on chapter 1
1 parent 1dc11c4 commit d71a468

File tree

4 files changed

+82
-6
lines changed

4 files changed

+82
-6
lines changed

Images/function-syntax.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
3+
excalidraw-plugin: parsed
4+
tags: [excalidraw]
5+
6+
---
7+
==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'
8+
9+
10+
# Excalidraw Data
11+
12+
## Text Elements
13+
printf ^9fLvm8Vp
14+
15+
( ); ^BlqQlZn8
16+
17+
"hello world" ^BApUJcjQ
18+
19+
%%
20+
## Drawing
21+
```compressed-json
22+
N4KAkARALgngDgUwgLgAQQQDwMYEMA2AlgCYBOuA7hADTgQBuCpAzoQPYB2KqATLZMzYBXUtiRoIACyhQ4zZAHoFAc0JRJQgEYA6bGwC2CgF7N6hbEcK4OCtptbErHALRY8RMpWdx8Q1TdIEfARcZgRmBShcZQUebQBGOJ4aOiCEfQQOKGZuAG1wMFAwYogSbggAIXwARwBFfAAtDgAOFOLIWERyqCwoNpLMbmcAVgBmAE5tAAYZ2YA2ABYpuZ5h
23+
24+
/hKYIdHR7R4Fnnjm5oXx07OAdnXIChJ1bnHm8+1R4dPmseH44ZW1gshJBCEZTSbjxKbxbRnKHQ8YLK4QazKYLcKbw5hQUhsADWCAAwmx8GxSOUAMTxBDk8n9SCaXDYLHKTFCDjEfGE4kSDHWZhwXCBLLUiAAM0I+HwAGVYMiJIIPIL0ZicQB1W6Sbh8P4QBXYhCSmDS9CysrwpnAjjhHJoeLwti87BqTZWmbwxnCOAASWIltQuQAuvCheQMp7uBw
25+
26+
hGL4YQWVhyg1NibhCzzcxvWGI5qwghiNxHucLlNfu0GExWJx1eD4YwWOwOAA5ThiUGjVaJV7jSPMAAiaR62bQQoIYXhmkTxAAosEMllvX74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YLg+juBNDBD0eLBzJAV11MqASBppBlC0mfAcS4vAFHUAS/FqYbjPyCjUsocMfIBPRdwLF8GSWeCFd4CV1Lwx0vGb/W+89OIgOMU4KmNVwpnpqWjK
43+
44+
Y5QumiyZD8wF7gAqizYCIK5opGaDEQHjtW9NmaRLKT3JpMbVXIB2DcggbA2RxTxzgF5nz8d/OaqCy+ukjFGAAW0/gLrJRvKQLSOt+hochDogMHxnpqqI2QA1YF4RGCDDiluw1tiWrtGhDInd0752Bb5rADUyA01wjlvMiAcyQA==
45+
```
46+
%%

Images/function-syntax.svg

Lines changed: 2 additions & 0 deletions
Loading

content/Drafts/Chapter 1.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,44 @@ title: "Chapter 1: Introduction, How Computers Work, Memory Layouts, Data Types
44

55
This chapter is going to be a doozy. We'll start off by priming you with some of the prerequisite knowledge you need to know surrounding C.
66

7-
Let's start off with an example:
7+
Let's start off with a snippet that we'll be using throughout this chapter.
88

99
```C
1010
#include <stdio.h>
11-
12-
int main(){
13-
printf("Hello world!\n");
14-
return 0;
11+
int main(int argc, char **argv){
12+
    printf("hello world\n");
13+
    return 0;
1514
}
15+
```
16+
17+
This is most probably everyone's first C program. There's a lot to cover, and for today it's a whirlwind tour around all the important aspects you need to know surrounding this program. As an overview, we'll be covering:
18+
19+
1. How to create an executable out of written C code.
20+
2. C Code Compilation.
21+
3. A simple mental model of a process, and computer memory.
22+
4. Data types in C, and their operations.
23+
24+
Again, it's quite a few disparate topics, so we'll be dipping our toes only a little bit in every topic.
25+
26+
# Creating programs from C code
27+
28+
So let's say we had that snippet written down somewhere. How do we actually "run" the code? There are many ways we can get this down, but here's one of the simplest ways: An online compiler called [Godbolt](https://godbolt.org). We've used their sharing feature to actually already pre-write in the snippet for you, so you can pop open the site [here](https://godbolt.org/z/d7oK4sKEM). If you visit it, you should be greeted by this on the page.
29+
30+
![[godbolt-hello-world.png]]
1631
32+
On the left pane is where you'd write code, and the website will actually automatically try compiling whatever has been written in it. For now, since it has been pre-filled with our snippet, it has automatically compiled the the code. On the bottom right pane, you'll see the following:
33+
34+
```
35+
Program returned: 0
36+
Program stdout
37+
hello world
1738
```
1839
19-
This is most probably everyone's first C program. There's a lot to cover, and for today it's a whirlwind tour
40+
Ignoring the first 2 lines for now, you'll notice that the program has somehow output "hello world".
41+
42+
Let's look at the most likely line that made this happen: **line 4**. It reads `printf("hello world\n");`. What's that all about?
43+
44+
`printf` stands for "print format", and this is a **function** that we will **call** to output stuff to the screen.
45+
46+
47+
114 KB
Loading

0 commit comments

Comments
 (0)