如何修复.... 0xC0000005:访问冲突读取位置0xccdfc15c。 [英] How to fix .... 0xC0000005: Access violation reading location 0xccdfc15c.

查看:77
本文介绍了如何修复.... 0xC0000005:访问冲突读取位置0xccdfc15c。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行应用程序后,我在Visual Studio 2005中获得第一次机会异常错误......任何人都帮我修复此问题....谢谢



[来自以下评论的复制代码]

I am Getting First-chance exception error in Visual Studio 2005, after running the application... Anyone help me to fix this ....Thanks

[Copied code from below comment]

void CEditBox_1Dlg::OnBnClickedButton1()
{ 
    // TODO: Add your control notification handler code here 
    CString csSamplFreq; 

    char carrSamplFreq[50],csTemp[50]; 
    char *pcSamplFreq = NULL; 
    pcSamplFreq =(char*)carrSamplFreq; 

    m_CntrlDisplay.SetFocus(); 
    m_CntrlDisplay.GetWindowText(csSamplFreq); 
    strcpy(carrSamplFreq,(LPCSTR) (CStringA)csSamplFreq); 
    pcSamplFreq += usCurPos; 
    sprintf(csTemp,"%s",pcSamplFreq); 
    for(short sLoop = 0;sLoop<strlen((char*)csTemp);sLoop++) 
    { 
        *pcSamplFreq =csTemp[sLoop]; pcSamplFreq++; 
    } 
    *pcSamplFreq = '\0'; 
    csSamplFreq.Format(L"%s",carrSamplFreq); 
    m_CntrlDisplay.SetWindowText(csSamplFreq); 
    usCurPos++; 
    m_CntrlDisplay.SetSel(usCurPos,usCurPos); 
    //m_CntrlDisplay=atoi(carrSamplFreq); 
    m_TxtSamplingFrequency = carrSamplFreq; 
    UpdateData(false);
}

推荐答案

没有足够的信息来回答这个问题的细节。最常见的原因是:您正在尝试读取未分配的内存。



我建议你阅读:分析崩溃以查找应用中的安全漏洞 [ ^ ]。

请调试程序并检查错误。
There is not enough information to answer this question with details. The most often reason is: you're trying to read unallocated memory.

I would suggest you to read this: Analyze Crashes to Find Security Vulnerabilities in Your Apps[^].
Please, debug you program and check for errors.


Quote:

strcpy(carrSamplFreq,(LPCSTR)(CStringA)csSamplFreq);

strcpy(carrSamplFreq,(LPCSTR) (CStringA)csSamplFreq);

这不是分配(宽) CString 内容到字符数组。



This is not the correct way for assigning a (wide) CString content to character array.

引用:

pcSamplFreq + = usCurPos;

sprintf(csTemp,%s,pcSamplFreq);

pcSamplFreq += usCurPos;
sprintf(csTemp,"%s",pcSamplFreq);

我想 usCurPos 在那里失控。





我认为在你的情况下,如果你告诉我们想要实现什么而不是坚持修复丑陋的 CString-character数组混合物,那可能会更好。

I suppose usCurPos is out-of-control there.


I think in your case it would probably better if you tell us what are trying to achieve instead of insist on fixing the ugly CString-character array mixture.


Bin sprintf 并删除任何数组和指针。了解如何使用 std :: stringstream std :: string 。如果你还有问题,那就回来再问一遍。
Bin sprintf and get rid of any arrays and pointers. Learn how to use std::stringstream and std::string. If you've still got a problem then come back and ask again.


这篇关于如何修复.... 0xC0000005:访问冲突读取位置0xccdfc15c。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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