我想省略txt file.eg .... ÿ 0111111110111101100011011010010001
中的额外位,在这个字符串中我们要省略在保存二进制字符串时出现的额外位ÿ
。保存乐趣如下。请帮帮我。
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();
}
答案 0 :(得分:0)
在构建CFile::typeBinary
时将CFile::Open
传递给bitstream
。否则检查创建CString的内容(m_B
)。您看到的额外角色看起来像是字节顺序标记......
答案 1 :(得分:0)
void LFSR_ECDlg :: Onsave() { 这 - &GT;的UpdateData();
CFile bitstream;
char strFilter[] = { "Stream Records (*.mpl)|*.mpl| (*.pis)|*.pis|All Files (*.*)|*.*||" };
CFileDialog FileDlg(FALSE, ".mpl", NULL, 0, strFilter);
//插入//由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);
}