Resources for my books
- I maintain some resources and hints to accompany my books on GitHub.
- I recommend checking that the
info
documentation is installed with the commands:info as info ld info gcc info g++
Study Hints
- Here are handy reference sheets.
-
Do not copy and paste code. We all copy code, and we all like to see our programs work. Copy and paste is the fastest way to do that. But if you type in the program, even if you are copying it, you are forced to read every single character. This is the fastest way to learn the programming language. As you know, getting a single character wrong can mean the difference between a working and non-working program.
-
Do the exercises at the end of each chapter. If you get stuck, the answers are provided in Appendix E. Take a quick look at my solution to get a couple of hints, then return to working on the solution for yourself.
-
Read the error messages. When you make a mistake (yes, you will make them; so do I), the compiler and assembler programs provide error messages that usually give you a good clue about what your mistake is. For example, without having all the source code, can you tell me what my mistake is from this error message?
bob@bob-laptop:~/programing$ gcc -Wall copy_loop.c
copy_loop.c: In function 'main':
copy_loop.c:12: error: expected ',' or ';' before 'while'
copy_loop.c:10: warning: unused variable 'temp2'
copy_loop.c:9: warning: unused variable 'temp1'
You should be able to quickly spot the error in my C source code:
9 char *temp1 = p1;
10 char *temp2 = p2
11 12 while((*temp1=*temp2)!='\0')
-
If you have a bug in your program, explain your code to somebody else. Ask another programmer to help you find the bug. Go through it line by line, explaining the purpose of each line. Most of the time you will spot your error before the other person does.
Using the Book With Other Operating Systems
- I have verified that the programs in the book will run on OpenSolaris 2009.06 installed on an x86-64 system with the following changes:
-
Use the
-m64
option forgcc
. The default is 32-bit. -
Use the
-64
option foras
. The default is 32-bit. -
The system call codes (
eax
register in Table 8.3 on page 185) are:exit = 1
,read = 3
, andwrite = 4
. -
When writing a stand-alone assembly language program (Section 8.7, page 185) use the
-melf-x86-64
option for 64-bit.
-
- I believe they will also run under other Unix operating systems — Mac OS X, *BSD, etc. — with minor changes in the command line options.