|
|
struct ShowCharRange{
int x;
int y;
};
//// save struct
CPtrList g_Show_CString_Range;
//init CPtrList
for(int i=1;i<3;i+=2)
{
ShowCharRange *scr;
scr = (ShowCharRange *)malloc(sizeof(ShowCharRange));
memset(scr,0,sizeof(ShowCharRange));
scr->x = i;
src->y = i+1;
g_Show_CString_Range.AddTail(src);
}
free(src);
//ShowCharRange is struct
POSITION pst = g_Show_CString_Range.GetHeadPosition();
while(pst!=NULL) //iterator list
{
ShowCharRange const *showChar;
showChar = (ShowCharRange*)malloc(sizeof(ShowCharRange));
memset(showChar,0,sizeof(ShowCharRange));
showChar = (ShowCharRange*)g_Show_CString_Range.GetNext(pst);
int x = showChar->x;
int y = showChar->y;
CString str;
str.Format("x:%d,y:%d",x,y);
// show x and y error
//this position always show x and y equal 0
MessageBox(str,"test",MB_OK);
}
从CPtrList中取出的x和y要么都是0,要么就是很大的负数或正数...
|
|