
A long time ago... computers used relays instead of circuits. These relays
would go up and down, and up and down, and generally create a lot of heat.
So in the summer, the computer room would get quite hot and the programmers
would have to leave the windows open. Insects would get in and plant themselves
in the relays and get squished. After a while the computer would start
having errors and the programmers would have to literally get in and
de-bug the computer. We don't have relays anymore but somehow those
bugs find a way in!
THE COMPILER BUG:
any of an order (Hemiptera and esp. its suborder Heteroptera) of
insects that have sucking mouthparts, forewings thickened at the
base, and incomplete metamorphosis and are often economic pests --
called also true bug
cp ~escobj/public/emacs ~/.emacsShould do it. Now the next time you call up emacs, it will colorize any of your .C or .c files. It works best if you call up your file at the command line prompt:
emacs project1.C &
oddeven.C: In function `int main()':
oddeven.C:8: parse error before `>'
The first line tells you which function the error is in. In this
case the error is in the main function main().
The second line has a number. This number is the line number that
the error is occuring in. Finally, an often cryptic message follows
trying to describe the nuisance.
<iostream.h>. Same with `cin' and `endl'.
>' = you left out a ';' or mismatched '(' or '{'
Notes:
g++ -Wall -o doom doom.C
Now it's time to bring out the heavy guns. To use xxgdb, you must first compile with the -g option:
g++ -g -o bugged bugged.CThen issue the command:
xxgdb buggedNow you will see a window that is split in three sections, with the top half containing your source code, the middle half containing many buttons, and the bottom all this text garbage. Now go to the top half and click on a function that you want the program to stop at. In this case, we only have one function, main(). After you click on it, click on the "break" button in the middle section of xxgdb. Then press "run" and wait.
Soon a little red hand will appear with a blue arrow showing you that the program has run and now has stopped at the first point it could after the "break". Click on the "next" button and you will see the arrow move through your program. When you get to "cout", you will see the text appear on the bottom section of xxgdb. When you get to "cin", you will have to enter a number. Enter it in the bottom section of xxgdb.
Click on one of the variables, 'x'. Then click on the button, "display". You will see a tiny window appear on the bottom that says:
1: x = <The number you typed>
This will aid you immmensly in the future when you have big programs with loops and you want to keep track of your variables. In fact, if you are having problems with your first programming assignment, you will want to run xxgdb on it to see exactly what your loops are doing.
Now you should be able to step through the rest of the program by pressing "next".
Why doesn't the loop work?
John Escobar