Of Memory Management, Heap Corruption, and C++

后端 未结 12 1869
半阙折子戏
半阙折子戏 2020-12-01 02:54

So, I need some help. I am working on a project in C++. However, I think I have somehow managed to corrupt my heap. This is based on the fact that I added an std::stri

12条回答
  •  借酒劲吻你
    2020-12-01 03:47

    Your code as I can see has no errors. As has been said more context is needed.

    If you haven't already tried, install gdb (the gcc debugger) and compile the program with -g. This will compile in debugging symbols which gdb can use. Once you have gdb installed run it with the program (gdb ). This is a useful cheatsheat for using gdb.

    Set a breakpoint for the function that is producing the bug, and see what the value of exampleString is. Also do the same for whatever parameter you are passing to exampleString. This should at least tell you if the std::strings are valid.

    I found the answer from this article to be a good guide about pointers.

提交回复
热议问题