Learning C and Assembly – Weeks 3 & 4
Weeks 3 and 4 of my C and Assembly learning journey focused on pointers, continued practice with C fundamentals, and finding new project-based learning resources.
I combined Weeks 3 and 4 into one post since Week 2’s recap was delayed a bit with the Memorial Day holiday.
I’ve continued working through C Programming: A Modern Approach and hit the big topic everyone loves to hype up—pointers.
Surprisingly, they clicked with me right away. I’m guessing it’s the years of working in different languages and dealing with memory, hardware, and low-level details through other parts of my job. I came in expecting mental gymnastics and walked away thinking, “That’s it?”
What I worked on:
- Continued through the book’s chapters on pointers, arrays, and memory
- Practiced through exercises, tweaking them to reinforce solid practices
- Discovered a helpful GitHub repo full of project-based C tutorials I plan to work through
Wins
- Pointers didn’t defeat me!
- Found a ton of project ideas for applying what I’m learning
- Still keeping a mostly steady pace—even with everything else going on
Challenges
- The usual: life. Between work, family, and side projects, it’s a challenge to stay consistent. But I’ve managed at least an hour a day most days.
Takeaways
- My understanding of pointers is better than expected.
- Having real projects to apply these concepts is going to help cement them much faster than only working through isolated examples.
- Learning consistently—even in small daily doses—still adds up.
Here’s my version of the Craps game from the book’s exercise. It’s one of the more enjoyable ones so far and a good test of basic control structures and functions:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
int roll_dice(void);
void play_game(void);
int main(void)
{
srand((unsigned)time(NULL));
play_game();
return 0;
}
void play_game(void)
{
char answer;
int total;
int roll = 1;
int point;
bool gameOver = false;
do
{
total = roll_dice();
printf("You rolled %d\n", total);
if (roll == 1 && (total == 7 || total == 11))
{
printf("You win!\n");
gameOver = true;
}
else if (roll == 1 && (total == 2 || total == 3 || total == 12))
{
printf("You lose!\n");
gameOver = true;
}
else if (roll == 1)
{
printf("Your point is: %d\n", total);
point = total;
roll++;
}
else if (roll != 1 && total == point)
{
printf("You win!\n");
gameOver = true;
}
else if (roll != 1 && total == 7)
{
printf("You lose!\n");
gameOver = true;
}
else
{
roll++;
}
if (gameOver)
{
printf("Play again? ");
scanf(" %c", &answer);
gameOver = false;
roll = 1;
}
} while (answer != 'n');
return;
}
int roll_dice(void)
{
int dice1;
int dice2;
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
return dice1 + dice2;
}