Ok, so you're trying to check for 5-in-a-row diagonally in any direction? I would probably do something like the following:

Code:

int y, x, win;
win = 0;
for (y=0; y<19; y++)
{
for (x=0; x<19; x++)
{
if (grid[y][x] == 'x')
{
ydir = -1;
xdir = -1;
if (five_in_a_row(grid, y, x, ydir, xdir))
{
win = 1;
break;
}
ydir = -1;
xdir = 1;
if (five_in_a_row(grid, y, x, ydir, xdir))
{
win = 1;
break;
}
ydir = 1;
xdir = -1;
if (five_in_a_row(grid, y, x, ydir, xdir))
{
win = 1;
break;
}
ydir = 1;
xdir = 1;
if (five_in_a_row(grid, y, x, ydir, xdir))
{
win = 1;
break;
}
}
}
}
if (win == 1)
{
printf("You win!\n");
}
.
.
/* Function five_in_a_row */
int five_in_a_row(char grid[19][19], int y, int x, int ydir, int xdir)
{
int count;
for (count=0, count<4; count++)
{
y += ydir;
x += xdir;
if (y>=0 && y<19 && x>=0 && x<19 && grid[y][x] == 'x')
{
continue;
}
else
{
return 0;
}
}
return 1;
}

You could also use function five_in_a_row() to check for wins horizontally and vertically by setting xdir or ydir to 0. And you could make an array of xdir and ydir to cover all the directions, thereby making the code shorter. There's probably many different ways to do this. This is just one idea.