如何查找下标越界的位置

yangyongde2002 yangyongde2002 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
程序偶尔能正常运行,偶尔不能。
挂掉的时候提示Microsoft Visual Studio C Runtime Library has detected a fatal error in myprogram.exe.
Press Break to debug the program or Continue to terminate the program.

下面是debug时的信息。

Debug Assertion Failed!
File: ...\vector
Line: 764

Expression: vector subscript out of range

For information on how your program can cause an assertion failure, see the Visual C++ document on asserts.


给出的提示是下标越界,我怎么去找哪个语句出现了越界啊?
因为程序比较长,单步运行比较困难,并且有些时候这个错误还不出现。

另外,我也读了一天代码了,也没有看出来哪有越界的。

有没有什么好的办法找到越界的位置啊?
...全文
评论 18
收藏 已收藏
分享
返回顶部
yangyongde2002
C++ 语言 65,214 成员 250,514 内容