typedef struct dlistclient{
int x,y;
CString name;
CString address;
struct dlistclient *prior,*next;
}DListClient;
typedef DListClient *DLinkList;
DLinkList listhead;void CMainFrame::creatlist()
{
DListClient *s=new(DListClient);//=malloc(sizeof(DListClient));
s->next=NULL;
s->x=10;
s->name=strname;
if(listhead==NULL)
{
listhead=new(DListClient);
listhead=s;
listhead->prior=NULL;
}
else
{
listhead->next=s;
s->prior=listhead;
//listhead=s;
}
delete s;
//free(s);}void CMainFrame::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString s;
if(listhead!=NULL)
{
s=listhead->name;//程序运行到此问题
}
if(listhead->next!=NULL)
{
s=listhead->next->name;
}
*pResult = 0;
}错误提示:
提示
Unhandled exception in newsrtuct.exe(MFC42D.DLL):0xC000005:Access Violation
如果不写 delete s;和 //free(s);就没问题
可是不是明明大家说要内存要回收吗?好多书上也是这样介绍的啊!!
int x,y;
CString name;
CString address;
struct dlistclient *prior,*next;
}DListClient;
typedef DListClient *DLinkList;
DLinkList listhead;void CMainFrame::creatlist()
{
DListClient *s=new(DListClient);//=malloc(sizeof(DListClient));
s->next=NULL;
s->x=10;
s->name=strname;
if(listhead==NULL)
{
listhead=new(DListClient);
listhead=s;
listhead->prior=NULL;
}
else
{
listhead->next=s;
s->prior=listhead;
//listhead=s;
}
delete s;
//free(s);}void CMainFrame::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString s;
if(listhead!=NULL)
{
s=listhead->name;//程序运行到此问题
}
if(listhead->next!=NULL)
{
s=listhead->next->name;
}
*pResult = 0;
}错误提示:
提示
Unhandled exception in newsrtuct.exe(MFC42D.DLL):0xC000005:Access Violation
如果不写 delete s;和 //free(s);就没问题
可是不是明明大家说要内存要回收吗?好多书上也是这样介绍的啊!!
解决方案 »
- 请教个问题,vc高手进入 在线等
- 如何在已写好的SDI程序前再加个选择框?类似Nehe教程全屏与否的对话框。
- 对话框的错误
- unsigned char(无符号的)是什么意思??
- 在线等,如果是高手,请帮我解决一个关于包含别人工程中类的问题。
- 调试状态下程序运行完全正常,但如果单独运行,总有问题。什么原因
- CString 到LPTSTR的转换,怎么转呢?
- 在程序中使用vc中默认的打印预览,关闭预览后,发现程序的标题变成了“无标题”,这是为什么?!如何解决?在线等待……
- 请问怎么用API函数求鼠标左右键的状态?
- ?在CPropertySheet和page组成的程序中,如何知道我的程序已经退到后台(或者说失焦)
- 一个关于Windows磁盘空间满的问题
- 愿500分奉送!请赐教...
int x,y;
CString name;
CString address;
struct dlistclient *prior,*next;
}DListClient;
typedef DListClient *DLinkList;DLinkList listhead = NULL;void CMainFrame::creatlist()
{
DListClient *s=new(DListClient);//=malloc(sizeof(DListClient));
s->next=NULL;
s->x=10;
s->name=strname;
if(listhead==NULL)
{
listhead=s;
listhead->prior=NULL;
}
else
{
listhead->next=s;
s->prior=listhead;
listhead=s;
}
}void CMainFrame::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString s;
if(listhead!=NULL)
{
s=listhead->name;//程序运行到此问题
}
if(listhead->next!=NULL)
{
s=listhead->next->name;
}
*pResult = 0;
}
可是不是明明大家说要内存要回收吗?好多书上也是这样写的啊!!
为什么这里不能用啊!!!!!!!!!