This code
Code:
index --;
if(index < 0) index += 3;
putchar(array[index]); /* C */
shows you how to handle going left, and the ++ part shows you how to handle going right.
You could use it like so:
Code:
void fill(int x, int y, char *a, int index, int i)
{
if ((screen[x][y] != ' ')|| (x > 65))
return;
if(index < 0) index += a_max;
if(index >= a_max) index -= a_max;
screen[x][y] = *a;
a++;
if(*a == '\0')
a-=i;
fill(x+1,y,a,index+1,i);
fill(x-1,y,a,index-1,i);
fill(x,y-1,a,index,i);
fill(x,y+1,a,index,i);
}
a_max is the number of characters in a. You could use strlen() for it.