当我发现它仅适用于Linux时,我正在研究Valgrind以帮助改进我的C编码/调试 - 我没有其他需要或兴趣将我的操作系统转移到Linux所以我想知道是否有一个同样好的Windows程序.
如何删除我在下面的代码中指定的指针:
char* ptr;
ptr=new char(65); // memory for one char is created and is assigned 'A'
strcpy(ptr,"asdf"); // how can string of length 4 chars are copied
delete ptr; // why am I getting debug error of Heap corruption detected
Run Code Online (Sandbox Code Playgroud)
我正在使用Visual C++ 2005