help please

i am trying to make a bullet disappear after colliding with a wall or anything but the game crashes at the 3rd bullet and i don't know why

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
struct bullet
{
	int cb;
	int rb;
	bullet()
	{
		cb=0;
		rb=0;
	}
	void move_b(int rb,int &cb,char xMem[][160])
	{
	
		  cb+=2;
		
	}
	void set_b (int &cb,int &rb,char xMem[][160])
	{
		
        xMem[rb][cb+1]='*';

	}
};
 if(k == 'f')
 {
       n++; // counter of bullets
 }
if(k == 'f')
{
       m[n].cb = CH;
       m[n].rb = RH;
} 
for(int v=0; v<=n ;v++,t--)
{
   if(xMem[m[t].rb][m[t].cb+1]==' ')
   {
	 m[t].move_b(m[t].rb,m[t].cb,xMem);
   }
   if(xMem[m[t].rb][m[t].cb+1]==' ')
   {
	 m[t].set_b(m[t].cb,m[t].rb,xMem);
   }
}

Last edited on
It is most likely because one of the indexes is out of bounds.
Topic archived. No new replies allowed.