bully....maguire's blog

By bully....maguire, 4 years ago, In English

I have watched screen cast of few red coders like SecondThread and i have seen that they debug just by looking at code . I usually use GDB for c++ for debugging. I wanted to know what are different possible ways to debug our program without using any print statement or any other tool like GDB.

Also i have to debug a lot . Is there some way to improve in this regard ?

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

With enough practice you'll be able to tell exactly what your code does just by reading it. That's all that's happening it's the same way you would read a book in another language. You'll have to get good at the language to understand it without help

»
4 years ago, # |
  Vote: I like it +4 Vote: I do not like it

I also add print statements to binary search where the problem is. If you have a break case and you know your code should get it right but isn’t, you can trace through it with print statements to find your typo if you don’t see it just by looking. It’s definitely a good skill to have, especially when you’re just starting. Once programs hit a certain complexity they are so long that you can’t always just see the bug by reading code.