Блог пользователя bully....maguire

Автор bully....maguire, 4 года назад, По-английски

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 ?

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

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.