Iv written a C program for playing tic-tac-toe between a computer and a user. Iv used lots of pointer variables and passing those variables to functions to functions. Im getting some warnings and also the program is not executing properly. I dont know whether it is because of warnings or I did logical errors in the program.
WARNING:
1. assignment makes a pointer from Integer without a cast.
2. passing arg1 of 'display' from incompatible pointer type.
Could anybody help me to give solution to this warning. It will be better if you guide why im not getting the expected output.
Below I place the error code. If u have to see my whole program for better checking it go to http://paste.pocoo.org/show/250129/
Compiled in gcc..
WARNING:
1. assignment makes a pointer from Integer without a cast.
2. passing arg1 of 'display' from incompatible pointer type.
Could anybody help me to give solution to this warning. It will be better if you guide why im not getting the expected output.
Below I place the error code. If u have to see my whole program for better checking it go to http://paste.pocoo.org/show/250129/
Compiled in gcc..
Code:
#include<stdio.h>
#include<stdlib.h>
void display();
int main()
{
int *a[3][3],i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
a[i][j]=0;
}
a[1][1]=1; //this is where I get the first warning
display(&a); //and the second warning is this
return 0;
}
void display(int *p)
{
int *a[3][3],i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
a[i][j]=*p;
p++;
printf("%d\t",a[i][j]);
}
printf("\n");
}
}
Comment