如何省略文件中的额外位?
我想省略 txt 文件中的额外位。例如 ....ÿ 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();
}
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您构造
bitstream
时,将CFile::typeBinary
传递给CFile::Open
。否则检查是什么创建了 CString (m_B
)。您看到的额外字符看起来像字节顺序标记......Pass
CFile::typeBinary
toCFile::Open
when you constructbitstream
. Otherwise check what is creating the CString (m_B
). The extra character you are seeing looks like a Byte Order Mark....无效 LFSR_ECDlg::Onsave()
{
这->UpdateData();
//插入//通过 TTT
}
void LFSR_ECDlg::Onsave()
{
this->UpdateData();
//insertion//by TTT
}