解决问题 [英] atoi Giving Problems

查看:95
本文介绍了解决问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的这段代码有问题,它给了我这个错误.
Eyeball.exe中0x5518c1a8(msvcr100d.dll)的未处理异常:0xC0000005:访问冲突读取位置0x525c3a43.

这是代码...

I''m having a problem with this segment of my code, It gives me this error.
Unhandled exception at 0x5518c1a8 (msvcr100d.dll) in Eyeball.exe: 0xC0000005: Access violation reading location 0x525c3a43.

This is the code...

if ((argc>=4) && (strcmp(argv[3], "m")==0))
    more=1;
result = atoi(argv[2]);
packetCount=0;

推荐答案

您传递给atoi的字符串是 not null终止

您的参数少于3个.您尚未确保拥有3个参数,因此result = atoi(argv[2]);可能会失败.

使用调试器逐行浏览代码,将使您能够找到失败的行,并且对您来说更应该清楚错误的原因是什么.
the string you pass to atoi is not null terminated

you have less than 3 arguments. You haven''t ensured that you have 3 arguments thus result = atoi(argv[2]); might fail.

Stepping through your code line by line, with the debugger, will allow you to find the line that fails and it should be more obvious to you what the reason for the error is.


这篇关于解决问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆