What's your method for finding the cause of a segfault?

后端 未结 6 399
不知归路
不知归路 2021-01-14 07:51

Or just debugging in general, how do you like to go about finding bugs in code. Specifically for C/C++, but all languages in general. I\'ve been trying to find the cause of

6条回答
  •  没有蜡笔的小新
    2021-01-14 07:55

    If you're in a fancy IDE try to familiarize yourself with breakpoints, you can use them to see how far you get into your code before the segfault happens. If you don't have that option, the simplest way is to comment out parts of your code one at a time until you find what is breaking.

    I have found the commenting out method to be pretty efficient for finding segfaults in small homework sized C problems.

提交回复
热议问题