char arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
char var;
// Asking input from user
for (int l = 0; l < 3; l++)
{
for (int k = 1; k < 3; k++)
{
if (k % 2 != 0)
{
var = get_int("Enter position for x: ");
strcpy(arr[l][k], "x");
}
else
{
var = get_int("Enter position for o: ");
strcpy(arr[l][k], "o");
}
design(var, arr);
}
}
arrays/ $ make tictactoe
tictactoe.c:20:24: error: incompatible integer to pointer conversion passing 'char' to parameter of type 'char *'; take the address with & [-Werror,-Wint-conversion]
strcpy(arr[l][k], "x");
^~~~~~~~~
&
/usr/include/string.h:141:39: note: passing argument to parameter '__dest' here
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
make: *** [<builtin>: tictactoe] Error 1
arris defined aschar arr[3][3], soarr[l][k]is achar.strcpyexpects achar *, a pointer to achar, and more specifically a pointer to the first of a series ofcharto which it will copy a string (a NUL-terminated sequence ofcharvalues).Looks like you want
arr[l][k] = 'x';.Other issues:
arrthat way?kis the horizontal offset, why do you use it to determine whetherxoroshould be used?varused anywhere?