Coder Social home page Coder Social logo

zedshaw / learn-c-the-hard-way-lectures Goto Github PK

View Code? Open in Web Editor NEW
1.2K 1.2K 483.0 1.6 MB

All of the code from Learn C The Hard Way, each project, plus the presentation slides used in the videos.

License: Other

C 34.28% HTML 22.62% CSS 22.15% JavaScript 19.33% Makefile 1.07% Shell 0.46% Python 0.09%

learn-c-the-hard-way-lectures's People

Contributors

runsfor avatar zedshaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learn-c-the-hard-way-lectures's Issues

Tiny virtual machine chapters?

Hello, thank you for your books!
I’ve recently received the printed version of LCTHW and noticed that Tiny Virtual Machine chapters are not there. I’ve seen these chapters in contents on some screenshots. It’s interesting topic to try, so maybe you have these chapters laying somewhere in your archives.

Thanks!

Ex22.c does not compile due to partial refactor

It seems an update of ex22.h where the global variable THE_SIZE was replaced by a struct is preventing the program ex22.c from compiling, because the function print_size() still works with the global variable which is now not declared or defined.

Few typos on the beginning sections of LCTHW

Hello Zed! Just started the lectures and purchased the book and the videos and just finished the first few exercises and all is going well so far. noticed a few typos on the digital PDF that came with the purchase and not sure if these have already been fixed but figured I should let you know.

I am hoping that my attention to detail on what I am ready gets translated to what I am actually coding... ;-)

Thanks again!
Adam

lcthw-1
lcthw-2 duplicate words
lcthw-3 - from not form

ex2: Makefile

The make command is quite confusing me while i carefully read your book and search some online website to deal with such error. I am running gedit on Linux machine in VMWare Workstation with terminal for make command running.
I tried to run ex1.c like this way:
make ex1
It runs successfully. But the problem to not understanding even I have watched your video lectures. I did not quite understand as it is so confusing and you run so fast to cover that issue.
The issue is where to place that Makefile. Actually problem to not pick up you are using vim editor. Where this Makefile should we place like. If I have the path of ex1 of lcthw\ex01\ex1.c then should i place makefile in this folder or the current folder in which i am going to place all exercise folder like lcthw\makefile thats it. and second thing is:
what is the extension of Makefile (.txt) or nothing to place anything after Makefile.
When i tried to run
make clean
I see this error message. How to clean this message.
make: *** No rule to make target `clean'. Stop.
I tried to check about the 4 spaces before (pne tab which is I set it 4 spaces in preferences in gedit)
1 CFLAGS=-Wall -g
2
3 clean:
4 rm -f ex1

Same question is asked over stackexchange twice. But still I am seeing ambiguity
http://stackoverflow.com/q/31704764
http://stackoverflow.com/q/22255085
Suggestion for correction in pdf book:
The snapshot of Exercise 2 session which is as under:
$ make clean
rm -f ex1
$ make ex1
cc -Wall -g ex1.c -o ex1
ex1.c: In function 'main':
ex1.c:3: warning: implicit declaration of function 'puts'
Error "puts" needs to be replaced with printf function If see the error again please.

Wrong exercise number listed for ex1

Hi, thanks for all the work putting this together!

I started working through the first chapter and saw a potential typo on pages 24-25 in the "Breaking It Down" section. The text references ex5.c:1 but I think it should have said ex1.c:1. The ex5.c file was referenced a few times for each line of code.

Is there an errata page for little things like this?

Ex28: C-skeleton Makefile fails to link the dl library

When using the Makefile from the book/repo, the dl library is not linked, causing compilation to fail due "undefined reference to ".
Relevant log:

[root@localhost exercise29]# make all
cc -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG  -fPIC   -c -o src/libex29.o src/libex29.c
ar rcs build/libex29.a src/libex29.o
ranlib build/libex29.a
cc -shared -o build/libex29.so src/libex29.o
cc -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG  build/libex29.a    tests/ex29_tests.c   -o tests/ex29_tests
/tmp/cc6B8uPY.o: In function `main':
/root/exercise29/tests/ex29_tests.c:16: undefined reference to `dlopen'
/root/exercise29/tests/ex29_tests.c:20: undefined reference to `dlsym'
/root/exercise29/tests/ex29_tests.c:29: undefined reference to `dlclose'
/root/exercise29/tests/ex29_tests.c:17: undefined reference to `dlerror'
/root/exercise29/tests/ex29_tests.c:21: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
make: *** [tests/ex29_tests] Error 1

Looking at the output, we can see that the -ldl flag is not added to the compilation command.
Changing line 2 in the Makefile from LIBS to LDLIBS solves that problem, and ex29_tests gets compiled properly.

[root@localhost exercise29]# make all
cc -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG  -fPIC   -c -o src/libex29.o src/libex29.c
ar rcs build/libex29.a src/libex29.o
ranlib build/libex29.a
cc -shared -o build/libex29.so src/libex29.o
cc -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG  build/libex29.a    tests/ex29_tests.c  -ldl  -o tests/ex29_tests
sh ./tests/runtests.sh
[root@localhost exercise29]# 

ex15: broken

This should be int *cur_age = ages; as it is in the book:

int *cur_age = (int *)names;

Reminder: '(int *)names;' is what you used in the last video lecture "Breaking it" example (around the 35 minutes mark). So, the code compiles but the 2nd and 3rd examples don't work.

ex17.c

Tried this lesson, but got error. Have retyped it from book, but same thing happens! Could somebody help me with it?:zipper_mouth_face: Im on Windows.

app.exe db.dat c

Creates file db.dat 101kb size

app.exe db.dat s 1 zed [email protected]

Fires
ERROR: Failed to load database.

Debugger said it happends at fread(), it returns 0 somehow

int rc = fread(conn->db, sizeof(struct Database), 1, conn->file);

void Database_load(struct Connection* conn)
{
	int rc = fread(conn->db, sizeof(struct Database), 1, conn->file);
	if (rc != 1)
		die("Failed to load database.");
}

For loops: counter is incremented after condition is met, not after code is run

I'm loving the book so far, and this is not that big of a deal. But for completeness, I thought I'd mention it. I hope I don't come off as pretentious, but you did say that we ought to inform you should we find any mistakes.

In page 55, you say "After the CODE runs, the INCREMENTS part is run, usually incrementing something such as in i++".

However, as I was playing around in the debugger, I noticed that the counter is incremented after the condition is met (even before the contents execute).

See the image below:
Screenshot 2024-05-23 at 16 26 33

These were the following commands I used:

p i
n
p i

As you can see, at line 7 even before the printf statement was executed, i had incremented.

I could be wrong, but I thought I'd just share anyway. Thanks for writing this book, though. I didn't realise that drills could be so useful for understanding concepts well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.