Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Debugging?
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Geminias




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Thu Sep 22, 2005 3:59 pm   Post subject: (No 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.
beard0




PostPosted: Thu Sep 22, 2005 4:10 pm   Post subject: (No 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.
wtd




PostPosted: Thu Sep 22, 2005 4:13 pm   Post subject: (No 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.
Geminias




PostPosted: Thu Sep 22, 2005 4:21 pm   Post subject: (No subject)

thanks Smile
wtd




PostPosted: Thu Sep 22, 2005 4:27 pm   Post subject: (No 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
[Gandalf]




PostPosted: Thu Sep 22, 2005 5:31 pm   Post subject: (No subject)

Hehe, but wtd, shouldn't it be:

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




PostPosted: Thu Sep 22, 2005 5:37 pm   Post subject: (No subject)

And I should have used prefix ++, and meaningful names. The key is the semi-colon.
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Thu Sep 22, 2005 5:44 pm   Post subject: (No 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.
wtd




PostPosted: Thu Sep 22, 2005 5:47 pm   Post subject: (No 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
[Gandalf]




PostPosted: Thu Sep 22, 2005 5:48 pm   Post subject: (No subject)

Oh. Good point Smile.
1of42




PostPosted: Thu Sep 22, 2005 6:00 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: