本文介绍了从文件加载时显示垃圾邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调用此函数将垃圾字符显示为UNICODE类型项目中的最后一项

Calling this function showing junk charecter as last item in an UNICODE type project

//Member Function to Read Data From File And Store it in List Control
void CDataFunction::WriteFunction(CListCtrl* pListCtrl,CString* m_pFileName)
{
    m_VFlag=TRUE;
    m_VNumlist=1;
    m_VFileName = (m_pFileName->GetString());
    //Clear All Data In List Control
    pListCtrl->DeleteAllItems();
    WCHAR m_VStrBuf[256],m_VTemp[100];
    //Read All The Data in File and Store in a Buffer
    GetPrivateProfileString(_T("List1"),NULL,NULL,m_VStrBuf,256,m_VFileName);
    //Insert the Read Data into The List Control
    for(int i=0;i<=256;i++)
    {
        if(m_VStrBuf[i]!='\0')
        {
            m_VFlag=TRUE;
            for(int j=0;m_VFlag==TRUE;j++)
            {
                m_VTemp[j]=m_VStrBuf[i+j];
                if(m_VStrBuf[i+j]=='\0')
                {
                    m_VTemp[j+1] ='\0';
                    pListCtrl->InsertItem(m_VNumlist,m_VTemp);
                    m_VNumlist++;
                    m_VFlag=FALSE;
                    i=i+j;
                }
            }
        }
    }
}

推荐答案


for(int i=0;i<=256;i++)




with

for(int i=0;i<256;i++)




-----编辑-----

您的评论暗示您实际上想要从垃圾中区分出返回的值.然后,您应考虑此函数的返回值,如其所述规范 [ ^ ].它还可以告诉您何时提供的缓冲区太小(因此256个字节不足)




----- EDIT -----

Your comment implies that you actually want to distinct returned values from junk. Then you should consider this function return value, as described it its specification[^]. It can also tell you when buffer provided is too small (so 256 bytes are not enough)


这篇关于从文件加载时显示垃圾邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:09