游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1324|回复: 0

CPtrList保存Struct!!!在线急等!!!

[复制链接]

4

主题

6

帖子

6

积分

新手上路

Rank: 1

积分
6
发表于 2009-3-25 11:46:00 | 显示全部楼层 |阅读模式
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,要么就是很大的负数或正数...

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-20 00:41

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表