tags:

views:

110

answers:

2

I want to omit extra bit in txt file.eg ....ÿ 0111111110111101100011011010010001 in this string we want to omit extra bit ÿ which is appeared when we save a binary string. Save fun is as follow. please help me.

void LFSR_ECDlg::Onsave() 
{
    this->UpdateData();

    CFile bitstream;
    char strFilter[] = { "Stream Records (*.mpl)|*.mpl| (*.pis)|*.pis|All Files (*.*)|*.*||" };

    CFileDialog FileDlg(FALSE, ".mpl", NULL, 0, strFilter);



    if( FileDlg.DoModal() == IDOK )
    {
        if( bitstream.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite) == FALSE )
            return;
        CArchive ar(&bitstream, CArchive::store);


        CString txt;
        txt="";
        txt.Format("%s",m_B);//by ANO
        AfxMessageBox (txt);//by ANO
        txt=m_B;//by ANO
        ar <<txt;//by ANO

        ar.Close();
    }
    else
        return;

    bitstream.Close();
}
A: 

Pass CFile::typeBinary to CFile::Open when you construct bitstream. Otherwise check what is creating the CString (m_B). The extra character you are seeing looks like a Byte Order Mark....

Billy ONeal
thank you for your help. m_B is Cstring.
thinthinyu
We can solve above problem by using this code. thank to all.
thinthinyu
A: 

void LFSR_ECDlg::Onsave() { this->UpdateData();

CFile bitstream;
char strFilter[] = { "Stream Records (*.mpl)|*.mpl| (*.pis)|*.pis|All Files (*.*)|*.*||" };

CFileDialog FileDlg(FALSE, ".mpl", NULL, 0, strFilter);

//insertion//by TTT

CFile cf_object;
if( FileDlg.DoModal() == IDOK ){
cf_object.Open( FileDlg.GetFileName(), CFile::modeCreate|CFile::modeWrite);
//char szText[100];
//strcpy(szText, "File Write Test");
    CString txt;
    txt="";
    txt.Format("%s",m_B);//by ANO
    AfxMessageBox (txt);//by ANO
int mB_size=m_B.GetLength();
cf_object.Write (m_B,mB_size); 

}

thinthinyu