recursive blob finder

i have to write a recursive function to count the number of blobs (grouping of characters) that are in a file. it is counting 7 blobs instead of the 6 that it should be. my function looks like this:

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
43
44
45
 for (rowIndex = 1; rowIndex < MAXROWS; rowIndex++)
		
			for (columnIndex = 1; columnIndex < MAXCOLUMNS; columnIndex++)

				if (blobArray[rowIndex][columnIndex] = ' ')
{
int count = 0;   // count for the number of blobs

	
					myArray [row][column] = ' ';

					if (myArray[row-1][column+1] != ' ')//up and right
					{
					  eraseAndTrack(myArray, row-1, column+1);
					}
					if (myArray[row][column+1] != ' ')//right
					{
					  eraseAndTrack(myArray, row, column+1);
					}
				    if (myArray[row+1][column+1] != ' ')//down and right
					{
					  eraseAndTrack(myArray, row+1, column+1);
					}
				    if (myArray[row+1][column] != ' ')//down
					{
					  eraseAndTrack(myArray, row+1, column);
					}
					if (myArray[row+1][column-1] != ' ')//down and left
					{
                      eraseAndTrack(myArray, row+1, column-1);
					}
				    if (myArray[row][column-1] != ' ')//left
					{
                      eraseAndTrack(myArray, row, column-1);
					}
				    if (myArray[row+1][column-1] != ' ')//up and left
					{
                      eraseAndTrack(myArray, row+1, column-1);
					}
			        if (myArray[row+1][column] != ' ')//up
					{
                      eraseAndTrack(myArray, row+1, column);
					}
}


im not sure why its counting 7 instead of 6, can anyone help me?
thanks, Dave
Last edited on
If you want to check if something is equal use == instead of =
Not sure if that is the problem or not but you may want to check the if that only has one =
Topic archived. No new replies allowed.