Infinite loop???

Hi, I am getting an infinite loop from this very simple for loop and it's driving me nuts. It's actually written in C. Why is the for loop not working? BUFFER_SIZE = 5

This is the output (infinite):

w m: 1
m: 0
w m: 1
m: 0
w m: 1
m: 0
w m: 1
m: 0
w m: 1


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
void printResults()
{
	int m;
	
	printf("\n(buffers occupied: %d)\n", pindex-cindex); 			
	printf("buffers: ");
	printf(" %d  %d  %d  %d  %d\n",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4]);
	printf("          --  --  --  --  --\n");
	printf("          ");
	for (m = 0; m < BUFFER_SIZE; m++)
	{
		if(m == pindex && pindex != cindex) 
			printf("w   ");
		else if (m == cindex && cindex != pindex) 
			printf("r   ");
		else if (m = pindex && pindex == cindex) 
			printf("wr  ");
		else 
			printf("    ");
		
		printf("m: %d\n", m);
	}
	printf("\n\n");
	
	return;
}
Last edited on
Line 16. Assign or compare?
check line 16 lol
Topic archived. No new replies allowed.