April 12 C
I read chapters 9 and 10: functions, arrays in functions, program organization, basic docstrings, and global variables.
Exercises coming in a few days.
Here's a thing I'm wondering, and its really one of the keys to learning how to learn from a textbook (or other comparable source): which exercises do I do? On what basis do I select them? How many? This is actually one of the things I find most hard about (semi) autodidactic learning. But I guess that is really what I'm trying to get better at at Marlboro - the "liberal (science) arts" aspect of what I'm doing.
What do you think?
Here's the code I e-mailed you, below - its seg faulting. Maybe this would be a good time to go over how to debug with gdb?
Jim
In class we re-wrote this so that
- it's in two .c and one .h files (just to see how that works)
- put in print statements for debugging
- fixed the problem with the old version (wasn't swapping the numbers within the loop). It was simpler to use "big" as the "temp" storage for the swap.
- new versions are selection_lib and selection_main
We also did a short example session with the debugger :
$ gcc -g selection_lib.c selection_main.c -o selection_sort
$ gdb selection_sort
(gdb) start # get the program going
(gdb) list # see the C code where we are
(gdb) print variable # see something
(gdb) set variable=new # change something
(gdb) step # execute one line
(gdb) break function_name # set stopping place
(gdb) continue # keep going until next stopping place