我要实现从文本里读取多行式子到下拉框中,但我用ReadString总是只能读取一行,并且是乱码,新手菜鸟什么都不懂,求各位帮帮忙啊,下面是我的Combo Box以及List Box初始化的代码:
CStdioFile fp;
m_listBox.ResetContent();
int openfp = fp.Open(_T("F://Projects//Calculator//数据.txt"), CFile::modeRead, NULL);
if (!openfp)
{
CString s;
s = "无法打开存储文件!";
MessageBox(s);
}
CString str=_T("");
while (fp.ReadString(str))
{
m_list.AddString(str);
m_listBox.AddString(str);
}
fp.Close();
写入文本操作是:
UpdateData(true);
CFile fp;
int openfp = fp.Open(_T("F://Projects//Calculator//数据.txt"), CFile::modeReadWrite,NULL);
if (!openfp)
{
CString s;
s = "无法打开存储文件!";
MessageBox(s);
}
fp.SeekToEnd();
fp.Write(m_result,m_result.GetLength()*2);
fp.Close();
我的文本数据是这样的:
但运行结果是:
求教大神,最好能贴出点代码