Computer Science Canada

Debugging?

Author:  Geminias [ Thu Sep 22, 2005 3:53 pm ]
Post subject:  Debugging?

i'm coming across this term often and not sure exactly what it means or how to use it.

i'm using mingw compiler, textpad to write my source codes, and windows xp.

i looked to see if there's a section on debugging but didn't find anything. if there is and i just didn't see it just give me directions to it.

just looking to know how to use the debugger in mingw. thanks for your help.

Author:  [Gandalf] [ Thu Sep 22, 2005 3:59 pm ]
Post subject: 

As wtd said, your debugger should be your brain. Debugging means just that: de-bug-ing your program, taking out the bugs. Usually related to fixing a problem in the code, or error in the program. THere are programs which try to help this process, but I have never used them, and it is definately possible to do without them. Later on, when working with large programs you might want to look more into the subject, but now it doesn't especially matter.

Author:  beard0 [ Thu Sep 22, 2005 4:10 pm ]
Post subject: 

The term debugging comes from way back when vacuum tubes were still in use in computers, and moths would fly into them, causing programs to malfunction. Thus, debugging was necessary for programs to work. Found this out in my U of Ottawa programming course.

Author:  wtd [ Thu Sep 22, 2005 4:13 pm ]
Post subject: 

Read the error messages your compiler provides. They provide valuable information on where the error occurred.

Also, only solve the first error. Then recompile.

The reasoning is that often one error will cause code later in the program to appear broken, even though it's fine. Fixing one error often "fixes" several others.

Author:  Geminias [ Thu Sep 22, 2005 4:21 pm ]
Post subject: 

thanks Smile

Author:  wtd [ Thu Sep 22, 2005 4:27 pm ]
Post subject: 

Oh, and if you ever catch yourself writing something like:

c++:
for (int i = 0; i < n; i++);


Smack yourself upside the head. Wink

Author:  [Gandalf] [ Thu Sep 22, 2005 5:31 pm ]
Post subject: 

Hehe, but wtd, shouldn't it be:

c++:
for (int i(0); i < n; i++)

Author:  wtd [ Thu Sep 22, 2005 5:37 pm ]
Post subject: 

And I should have used prefix ++, and meaningful names. The key is the semi-colon.

Author:  [Gandalf] [ Thu Sep 22, 2005 5:44 pm ]
Post subject: 

Sure
Quote:
should have used prefix ++

That would matter on what you are trying to do, if you are counting from one then the postfix is what you need.

I think of 'i' as a meaningful variable name, from what I have seen it is pretty much globally used as a 'count' variable. Still, it's good practice... yes.

Author:  wtd [ Thu Sep 22, 2005 5:47 pm ]
Post subject: 

Here's a problem. Use grep to find every line which contains "i". Oh, wait... that returns every line in the program, pretty much. Wink

Author:  [Gandalf] [ Thu Sep 22, 2005 5:48 pm ]
Post subject: 

Oh. Good point Smile.

Author:  1of42 [ Thu Sep 22, 2005 6:00 pm ]
Post subject: 

[Gandalf] wrote:
Sure
Quote:
should have used prefix ++

That would matter on what you are trying to do, if you are counting from one then the postfix is what you need.

I think of 'i' as a meaningful variable name, from what I have seen it is pretty much globally used as a 'count' variable. Still, it's good practice... yes.


actually, in the context of that for loop, it doesn't matter at all, except in the snese that prefix is faster.


: