本文介绍了警告C4789:内存复制的目标太小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个C代码,我们之前使用较旧版本的VC ++编译,它运行良好。在升级过程中,我们使用Visual 2008 Express Edition来编译代码。代码编译良好并创建输出dll,但在运行时它显示内存异常。我们回到日志文件并检查警告消息。其中一条警告信息显示警告C4789:内存复制的目的地太小。导致此警告消息的代码如下: -



Hi,

I am having a C code which we compiled earlier using older version of VC++ and it worked fine. During our upgrade we are using Visual 2008 Express Edition to compile our code.The code is compiling well and creating an output dll, but during run time it is showing memory exception. We went back to log file and checked for warning messages. One of the warning message says warning C4789: destination of memory copy is too small. The Code which caused this warning message is as follows:-

memcpy(szOutputNum,
       pRPS->GroupName1,
       sizeof(pRPS->GroupName1)-1);





我们已经注释掉了这部分代码并再次创建了dll。这次我们运行应用程序时工作正常。但是我们在这段代码中有一个逻辑来创建一个我们需要的报告。



所以,你们中的任何人都可以帮助我解决这个问题。 />


谢谢,

S1



We have commented out this portion of code and created the dll again. This time when we run the application it is working fine. But we had an logic in this code to create a report which is required for us.

So, Can any one of you help me in resolving this issue.

Thanks,
S1

推荐答案


这篇关于警告C4789:内存复制的目标太小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:37
查看更多