未处理的异常VS2010 C ++ [英] Unhandled exception VS2010 C++

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

问题描述

我想在Windows上创建一个套接字以连接到服务器。



我使用msdn网站的代码,winsock客户端代码。

(链接:msdn.microsoft.com/en-us/library/windows/desktop/ms737591(v=vs.100).aspx)



在任何情况下,当我尝试调试所述代码,我得到错误消息:

 未处理的异常0x58a714cf msvcr100d.dll)在Application.exe:0xC0000005:访问冲突读取位置0x00000032。 

它询问我是否要断开或继续,如果我继续出现同样的错误信息,向上。如果我按break,它需要我到文件output.c中的1643行。



简单地说,我不知道该怎么做,使它工作,我



对所有发表的评论作出回复:

p>

output.c中的周围相关代码是:

  if &(FL_LONG | FL_WIDECHAR)){
if(text.wz == NULL)/ * NULL传递,使用特殊字符串* /
text.wz = __wnullstring;
bufferiswide = 1;
pwch = text.wz;
while(i--&& * pwch)
++ pwch;
textlen =(int)(pwch - text.wz);
/ * textlen现在包含宽字符的长度* /
} else {
if(text.sz == NULL)/ * NULL传递,使用特殊字符串* /
text .sz = __nullstring;
p = text.sz;
while(i--&& * p)//这是它的地方
++ p;
textlen =(int)(p - text.sz); / *字符串的长度* /
}

这不是我编写的代码但已经存在的先天代码。



编辑NR 2:
这是一个显示我的调用堆栈的打印屏幕。
我没有10个声望,所以我不能显示图像,所以这里是一个链接到图像:



http://tinypic.com/r/5n6ww9/5



您可以看到我的调用堆栈

解决方案

文件 output.c 处理 printf 系列函数的代码。



这里有一个错误的事实可能是由于在代码中出现格式错误的 printf 函数调用。可能您指定了无效的打印格式或没有提供足够的参数。



当程序崩溃时,单击Break并在调试窗口中查看调用堆栈, - 在你的代码中 - 函数被调用,并带有什么参数。



我怀疑你正在尝试打印一个NULL字符串或其他东西。当你发现 printf 调用(如果是这样),编辑你的问题来显示源代码部分和/或使用调试器来检查使用的变量



没有看到你编写的代码,在崩溃的位置,它是不可能给一个函数的参数,更准确的答案。


I am trying to make a socket on windows to connect to a server.

I am using the code from msdn's website, the winsock client code.
(Link: msdn.microsoft.com/en-us/library/windows/desktop/ms737591(v=vs.100).aspx )

In any case, when I try debugging said code I get the error message:

Unhandled exception at 0x58a714cf (msvcr100d.dll) in Application.exe: 0xC0000005: Access violation reading location 0x00000032.

It asks me if I want to break or continue, if I continue the same error message simply keeps popping up. If I press break it takes me to line 1643 in the file output.c .

Simply put, I have no idea about what to do to make it work, and I'd appreciate any help given.

EDIT:

A reply to all comments given thus far:

The surrounding relevant code in output.c is:

if (flags & (FL_LONG|FL_WIDECHAR)) {
                if (text.wz == NULL) /* NULL passed, use special string */
                    text.wz = __wnullstring;
                bufferiswide = 1;
                pwch = text.wz;
                while ( i-- && *pwch )
                    ++pwch;
                textlen = (int)(pwch - text.wz);
                /* textlen now contains length in wide chars */
            } else {
                if (text.sz == NULL) /* NULL passed, use special string */
                    text.sz = __nullstring;
                p = text.sz;
                while (i-- && *p) //THIS IS WHERE IT BREAKS
                    ++p;
                textlen = (int)(p - text.sz);    /* length of the string */
            }

This is not code that I have written but innate code that already exists.

EDIT NR 2: This is a printscreen displaying my call stack. I do not have 10 reputation so I cannot show the image, so here is a link to the image:

http://tinypic.com/r/5n6ww9/5

On it you can see my call stack

解决方案

The file output.c has the code that handles the printf family of functions.

The fact that you have an error here is probably due to a malformed printf function call in your code. Maybe you have specified an invalid print format or have not provided enough arguments.

When your program crashes, click Break and look at the call stack in the debugging windows to see where - in your code - the function is called, and with what arguments.

I suspect you are trying to print a NULL string or something. When you have found the printf call (if that's what it is), edit your question to show that section of source code and/or use the debugger to examine the variables used a arguments to the function and make sure they are all correct.

Without seeing the code that you've written, at the location of the crash, it's not possible to give a more precise answer.

这篇关于未处理的异常VS2010 C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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