[Error] 'size' undeclared here (not in a function)
I wrote a function called magic square and Functions should not have pointers implementations. I have stuck with the line int sq[size][size], int size and this prints out the error message. My code is below: #include<stdio.h> int count=1; int print(int sq[size][size], int size){ int i,j; for(i=0;i<size;i++){ for(j=0;j<size;j++) printf("%5d",sq[i][j]); printf("\n"); } } int init(int sq[size][size], int size){ int i,j; for(i=0;i<size;i++) for(j=0;j<size;j++) sq[i][j]=0; } int Algorithm(int sq[size][size],int size,int i, int j, int count){ int row,column; if(count>=size*size){ sq[i][j]=count; } else { sq[i][j]=count; row=(i-1<0)?(size-1):i-1; column=(j-1<0)?(size-1):(j-1); if(sq[row][column]){ i=(++i)%size; } else{ i=row; j=(j-1<0)?(size-1):--j; } Algorithm(sq,size,i,j,count+1); } } int main(void){ int i,j,row,col; int size; //detect the size printf("input the size of the square: "); scanf("%d",&size); while((!(size%2))||size>9||size<5){ printf("This is not a available number, plz try again:"); scanf("%d",&size); } int sq[size][size]; for(j=0;j<size;j++){ sq[size][size]=sq[size][j]; } //initialize the data init(sq,size); i=0; j=(size-1)/2; Algorithm(sq,size,i,j,count); printf("magic square of size %d : \n\n",size); print(sq,size); printf("\n\n"); } Can someone help me to fix this without using the pointer implementation. Thanks!