CString str="";
GetDlgItemText(IDC_EDIT1,str);//得到编辑框内容
CFile file;
file.Open("test",CFile::modeReadWrite);//打开文件
file.SeekToEnd();//文件指针到文件末尾
file.Write(str,str.GetLength());//写入文件
SetDlgItemText(IDC_EDIT1," ");
file.SeekToBegin();//文件的开始
str=" ";
char *c;
c=new char[file.GetLength()];//得到文件主长度
file.Read(c,file.GetLength());//读出数据
str=c;
SetDlgItemText(IDC_EDIT2,str);
编辑,链接,执行没问题,可是我一在EDIT1中输入数据时,按确定就出错。 以上是确定按钮的代码。
错误是:Debug Assertion Failde!
File:filecore.cpp
For information on how your program can cause an assertion failure ,see the Visual C++ documentation onasserts.
我是新手,问题也许很幼稚大家多帮忙。帮我看看怎么改 ,哪里的问题
GetDlgItemText(IDC_EDIT1,str);//得到编辑框内容
CFile file;
file.Open("test",CFile::modeReadWrite);//打开文件
file.SeekToEnd();//文件指针到文件末尾
file.Write(str,str.GetLength());//写入文件
SetDlgItemText(IDC_EDIT1," ");
file.SeekToBegin();//文件的开始
str=" ";
char *c;
c=new char[file.GetLength()];//得到文件主长度
file.Read(c,file.GetLength());//读出数据
str=c;
SetDlgItemText(IDC_EDIT2,str);
编辑,链接,执行没问题,可是我一在EDIT1中输入数据时,按确定就出错。 以上是确定按钮的代码。
错误是:Debug Assertion Failde!
File:filecore.cpp
For information on how your program can cause an assertion failure ,see the Visual C++ documentation onasserts.
我是新手,问题也许很幼稚大家多帮忙。帮我看看怎么改 ,哪里的问题
解决方案 »
- wise installation 快捷方式问题
- 为何我用wininet设置相同的代理服务器,在VC程序中响应速度比在IE中设置要慢很多?
- 按钮风格的问题!
- 如何制作一个虚拟摄像头,就像softcam151一样?
- 有用boost开发服务器的么?
- MFC DLL 动态链接库?
- ****谁有用MD5对文件加密的源程序?
- 文字拖动问题!!??
- 各位大侠帮个忙吧,急!急!急!(搞定马上送分)
- 高分求解,非高手莫入!!!!!!!!最后一次提问(300分,分十次给必给)
- 求救,展讯平台显示png图像
- ::SuspendThread( hThread1);这个函数怎么有时候可以暂停线程,有时候不可以暂停,我是在程序中创建10个线程,然后对应的去暂停,但是好像不
最笨的方法是在每一行代码下都加上MessageBox提示信息,看执行了多少个 MessageBox就知道代码运行到哪步出错了
SetDlgItemText(IDC_EDIT2,str);改成
str.Format("%s", c);
SetDlgItemText(IDC_EDIT2,str);试试
c=new char[file.GetLength()];//得到文件主长度
file.Read(c,file.GetLength());//读出数据
str=c;
SetDlgItemText(IDC_EDIT2,str);
->
DWORD len = file.GetLength();
char* c = new char[len+1];
memset(c, 0, sizeof(char)*(len+1));
file.Read(c, len);
str.Format("%s", c);
SetDlgItemText(IDC_EDIT2, str);
file.Close();
delete[] c;
c = NULL;