void CMy2Dlg::OnBUTTONsave()
{
// TODO: Add your control notification handler code here
FILE* ip = fopen("everett","wb");
if(!ip)
{
MessageBox("nothing");
return;
}
else
{
int a = 0;
while(a<m_access.GetItemCount())
{
CString st1,st2,st3;
st1 = m_access.GetItemText(a,0);
fwrite(&st1,sizeof(CString),1,ip);
st2 = m_access.GetItemText(a,1);
fwrite(&st2,sizeof(CString),1,ip);
st3 = m_access.GetItemText(a,2);
fwrite(&st3,sizeof(CString),1,ip);
a++;
}
fclose(ip);
}
}
void CMy2Dlg::OnBUTTONread()
{
// TODO: Add your control notification handler code here
m_access.DeleteAllItems();
if(m_access.DeleteAllItems())
{
FILE* ip = fopen("everett","rb");
if(!ip)
{
MessageBox("nothing");
return;
}
else
{
int a =0;
while(!feof(ip))
{
CString st1,st2,st3;
fread(&st1,sizeof(CString),1,ip);//为什么读不进去呢?大家帮帮忙看看这是一个读取保存过的文件 读到链表
fread(&st2,sizeof(CString),1,ip);//
fread(&st3,sizeof(CString),1,ip);//
m_access.InsertItem(a,st1);
m_access.SetItemText(a,1,st2);
m_access.SetItemText(a,2,st3);
a++;
}
fclose(ip);
}
}
else
{
MessageBox("delete wrong");
}}
{
// TODO: Add your control notification handler code here
FILE* ip = fopen("everett","wb");
if(!ip)
{
MessageBox("nothing");
return;
}
else
{
int a = 0;
while(a<m_access.GetItemCount())
{
CString st1,st2,st3;
st1 = m_access.GetItemText(a,0);
fwrite(&st1,sizeof(CString),1,ip);
st2 = m_access.GetItemText(a,1);
fwrite(&st2,sizeof(CString),1,ip);
st3 = m_access.GetItemText(a,2);
fwrite(&st3,sizeof(CString),1,ip);
a++;
}
fclose(ip);
}
}
void CMy2Dlg::OnBUTTONread()
{
// TODO: Add your control notification handler code here
m_access.DeleteAllItems();
if(m_access.DeleteAllItems())
{
FILE* ip = fopen("everett","rb");
if(!ip)
{
MessageBox("nothing");
return;
}
else
{
int a =0;
while(!feof(ip))
{
CString st1,st2,st3;
fread(&st1,sizeof(CString),1,ip);//为什么读不进去呢?大家帮帮忙看看这是一个读取保存过的文件 读到链表
fread(&st2,sizeof(CString),1,ip);//
fread(&st3,sizeof(CString),1,ip);//
m_access.InsertItem(a,st1);
m_access.SetItemText(a,1,st2);
m_access.SetItemText(a,2,st3);
a++;
}
fclose(ip);
}
}
else
{
MessageBox("delete wrong");
}}
解决方案 »
- 请教求最接近时间计算问题
- 【卖书】出售两本Ruby新书!
- 在VC的应用程序中怎样实现报表的自定义呢?请教大虾,现在都有什么方法
- 如何改变鼠标为漏斗的形状?(不在OnSetCursor是处理)急!!!!!!!!!!!!!!
- 如何使用sdk函数 得知打印机中的一个任务已经完成 (打印机设置为不记录已打印完作业)
- 怎样使edit box 的内容清除?(求救)
- 怎样编程分行打印LISTBOX里的字符!
- 程序中如何知道窗口尺寸变化了?
- 谁知道怎样在程序中得到由麦克风输入的声音并用音箱播放?
- (急):高手们帮我看看下面的代码
- [原创&交流]桌面程序调用Web Service应用实例
- VB中的“ Set Option2.Container = Frame1” 在VC 如何表达?
fwrite(&st1....),fread(&st1....)这样写,写入的是CString实例,而不是CString的内容
建议改用char*