Code:

int Process(char spaces[][8], int counter, int &group, int x, int y)
{
if(spaces[x][y] == "w")
{
counter++
if(spaces[x+1][y] == "w")
{
spaces[x][y] = "b";
return Process(spaces[x][y], counter, group, ++x, y);
}
if(spaces[x-1][y] == "w")
{
spaces[x][y] = "b";
return Process(spaces[x][y], counter, group, --x, y);
}
if(spaces[x][y+1] == "w")
{
spaces[x][y] = "b";
return Process(spaces[x][y], counter, group, x, ++y);
}
if(spaces[x][y-1] == "w")
{
spaces[x][y] = "b";
return Process(spaces[x][y], counter, group, ++x, --y);
}
}
else if(x == 8)
{
++y;
x = 0;
return Process(spaces[x][y], counter, group, x, y);
}
else if(y == 8)
{
return 1;
}
else
{
++group;
cout << counter;
return Process(spaces[++x][y], counter, group, x, y);
}
}