Try this verbose script for your first test:
/*
# ===============================================================
# SitePoint:
https://www.sitepoint.com/community/t/detecting-diagonals-in-2d-array-c/265418
# COMPILE
gcc -o executable-2-delete tic-tac-toe.c
# RUN
./executable-2-delete
// http://prntscr.com/fffdyh
// http://prntscr.com/fffec6
# ===============================================================
*/
#include <stdio.h>
#include <string.h>
#define SIZE 6
int iPassed, flag = 0;
char Boards[6][6] =
{
{'X', 'b', 'c', 'd', 'e', 'f'},
{'g', 'X', 'i', 'j', 'k', 'l'},
{'m', 'n', '?', 'p', 'q', 'r'},
{'s', 't', 'u', 'X', 'w', 'x'},
{'y', 'z', '1', '2', 'X', '4'},
{'5', '6', '7', '8', '9', 'X'}
};
//=====================
int main(int argc, char* argv[])
{
printf("\n ================================");
printf("\n Testing top-left to bottom-right");
printf("\n ================================");
// ASSUME PASSED
iPassed = 1;
// LOOP THROUGH ALL ITEMS
for (int row=0, col=0; row < SIZE; row++, col++)
{
printf("\n\t %d %d ==> %c", row, col, Boards[row][col]);
// TEST FOR SINGLE FAILURE
if ( Boards[row][col] != 'X' )
{
// FAILED
iPassed = 0;
printf("\t :( FAILED");
// break;
}
}//endfor
// RESULT
printf("\nRESULT:\t");
if( iPassed )
{
printf("PASSED");
}else{
printf("FAILED");
}//endif
printf("\n\n");
}//endmain ====================================
Output:
================================
Testing top-left to bottom-right
================================
0 0 ==> X
1 1 ==> X
2 2 ==> ? :( FAILED
3 3 ==> X
4 4 ==> X
5 5 ==> X
RESULT: FAILED
I would not like to give you a full solution to the second test but will mention it was a little more difficult