main.c:10:24: error: function definition is not allowed here int read( int a[9][9]){ ^
main.c:36:24: error: function definition is not allowed here void show(int a[9][9]){ ^
main.c:58:24: error: function definition is not allowed here void reset(int arr[9]){ ^
main.c:65:34: error: function definition is not allowed here
int counter(int arr[9], int val){
^
main.c:77:53: error: function definition is not allowed here int validBox(int a[9][9], int ioffset, int joffset){ ^
main.c:89:33: error: function definition is not allowed here int vaildRowColBox(int a[9][9]){ ^
main.c:122:12: error: function definition is not allowed here int main(){ ^
7 errors generated
1 /*
2
3
4 */
5
6 #include<stdio.h>
7
8 int main ()
9 {
10 int read( int a[9][9]){
11 int i, j, flag =0;
12 char ch;
13 for(i = 0; i < 9; i++){
14 for( j = 0; j < 9; j++){
15 a[i][j] = 0;
16 }
17 }
18
19 for(i = 0; i < 9; i++){
20 for(i = 0; j < 9; j++){
21 ch = getchar();
22 if(ch > '1' && ch <= '9')
23 a[i][j] = (int)ch - '0';
24 else
25 a[i][j] = 0;
26 }
27 }
28
29 if(ch == EOF){
30 printf("\nNot enough values read to fill 9x9 sudoku.\n");
31 retun 0;
32 }
33 return 1;
34 }
35
36 void show(int a[9][9]){
37 int i, j;
38 for(i = 0; i < 9; i++){
39 if(i%3 == 0)
40 printf("\n+---+---+---+");
41 printf("\n");
42 for( j = 0; j < 9; j++){
43 if(j%3 == 0)
44 printf("|");
45 if(a[i][j] == 0)
46 printf(" ");
47 else printf(a[i][j]);
48 }
49 printf("|");
50 }
51 printf("\n+---+---+---+\n");
52 }
53
54 //Validation Logic is here
55 //One 9 sized array "arr" is taken as counter
56 //The reset function resets to zero of the counter array"arr"
57
58 void reset(int arr[9]){
59 for(int i = 0; i < 9; i++){
60 arr[i] = 0;
61 }
62 }
63
64 //The counter dunction that counts the occurance of he number in perticular boz or row o r column
65 int counter(int arr[9], int val){
66 if(val == 0)
67 return 0;
68 if(arr[val -1]
69 return 1;
70 else{
71 arr[var-1] = 1;
72 return 0;
73 }
74 }
75
76 //The validBox function checks for each box and box decided by the offsets
77 int validBox(int a[9][9], int ioffset, int joffset){
78 int arr[9];
79 reset(arr);
80 for(int i = 0 + ioffset; i < 3+ioffset; i++){
81 for(int j = 0 + joffset; j < 3+joffset; j++){
82 if(counter(arr,a[i][j]))
83 return 1;
84 }
85 }
86 return 0;
87 }
88
89 int vaildRowColBox(int a[9][9]){
90 int arr[9];
91 reset(arr);
92
93 //Each Row
94 for (int i = 0; i < 9; i++){
95 for (int j = 0; j < 9; j++){
96 if(counter(arr,a[i][j]))
97 return 1;
98 }
99 reset(arr);
100 }
101 reset(arr);
102
103 //Each Column
104 for(int i = 0; i < 9; i++){
105 for(int j = 0; j < 9; j++){
106 if(counter(arr, a[i][j]))
107 return 1;
108 }
109 reset(arr);
110 }
111
112 //Each Box
113 for(int i = 0; i < 9; i+=3){
114 for(int j = 0; j < 9; j+=3){
115 if(validBox(a,i,j))
116 return 1;
117 }
118 }
119 return 0;
120 }
121
122 int main(){
123 int a[9][9];
124 int i, j;
125 if(read(a)){
126 if(validRowColBox(a)){
127 printf("The sudoku grid is not valid");
128 }
129 show(a);
130 }
131 return 0;
132 }
133
134 }
I am try to code a sudoku puzzles. Thank you