下のソースで、おかしい部分はないと思うのですが、
デバッグで見ていくと、ここで変わっているようなのです。
どこがおかしいと思われますか?
typedef struct door_t{ int x,y; int state; door_t *next; }; door_t *head_door;グローバル変数です。 #define COUNT_MAX 30 void out_hantei(){ door_t *p=head_door; int counter=0; while(p!=NULL){ p->x=(rand()%20)*32;//(1) p->y=(rand()%16)*30; printfDx("%d.%d\n",p->x,p->y); if(p!=head_door){ if(p->x=head_door->x && p->y==head_door->y){ while(p->x==head_door->x && p->y==head_door->y){//(2) p->x=(rand()%20)*32; p->y=(rand()%16)*30; printfDx("%d.%d\n",p->x,p->y); } } } p=p->next; counter++; } if(counter<COUNT_MAX){ int x=(rand()%20)*32,y=(rand()%16)*30; printfDx("%d.%d\n",x,y); enter_door(x,y,1); //enter_door((rand()%20)*32,(rand()%16)*30,1); }//enter_door(0,0,1); } で最初(head_door)のときは(1)の部分で 0x023649a8 {x=576 y=420 state=0 next=0x02361288 }//最初 0x02361288 {x=0 y=0 state=1 next=0x023612d8}//2番目。 0x023612d8 {x=160 y=30 state=1 next=0x00000000}//最後 で二回目(head_door->next)のときは(1)の部分で head_door = 0x023649a8 {x=32 y=330 state=0 next= 0x02361288}//最初 head_door->next = 0x02361288 {x=0 y=0 state=1 next =0x023612d8}//2番目。 (head_door->next)->next = 0x023612d8 {x=160 y=30 state=1 next = 0x00000000}//最後 で(2)の部分で head_door =0x023649a8 {x=32 y=330 state=0 next=0x02361288}//最初 head_door->next=0x02361288 {x=1 y=330 state=1 next=0x023612d8}//2番目。 (head_door->next)->next =0x023612d8 {x=160 y=30 state=1 next=0x00000000}//最後となって書き変わってしまうのです。どこが原因だと思われますか?