I have a problem with typecasting in C.

Let me explain my problem first: I have a 2-dimensional array of integers that is filled with numbers from 0-9 (its a sudoku and 0 means a empty space).

Then I have a second array and that is a 3-dimensional char array. It contains all the possible values for the empty spaces of my sudoku as a string "123456789". Now after I filled both of the 2 arrays (does work), I want to loop with 2 for loops over my int array and find all places where there is already a value from 1-9. I save that value in a temporary variable.

Then I want to loop over the char array and remove the value of the temporary variable from all lines and rows that are connected to the place where I found the value in the int array (like a real sudoku, every umber can only occur once in every line & row).

Well, to search a char array I need a char. But the temporary variable is an int so I have to typecast it and there is the problem.

```
for(j=0; j<9; j++){
for(k=0; k<9; k++){
if (grid[j][k] != 0){
help_variable_remove_pv = grid[j][k];
cast_number/*char*/ = (char) help_variable_remove_pv/*int*/;
printf("%c", cast_number);
printf("\n%d", cast_number);
}
}
}
```

I cast the int to a char. But when display it on the console to test it. I get a "smiley" when I print it as a char but it displays the actual number when I print as an integer. But I need the actual number in a char not in an int.

```
void sudoku_read(int sudoku[9][9])
int j, k;
char filename[100];
printf("Please enter file name: ");
scanf("%s", filename);
FILE *file1 = fopen(filename, "r");
for(j=0;j<9;j++){
for(k=0;k<9;k++){
fscanf(file1,"%d\t", &sudoku[j][k]);
}
}
fclose(file1);
void set_possible_values(char possible_values[9][9][10]){
int j, k;
char string [] = "123456789";
for(j=0;j<9;j++){
for(k=0;k<9;k++){
memcpy(possible_values[j][k], string, 10);
}
}
void sudoku_solve(int grid[9][9])
int j, k, a, b, i;
int help_variable_remove_pv;
char cast_number;
char possible_values[9][9][10];
char zero_string [] = "000000000";
set_possible_values(possible_values);
for(j=0; j<9; j++){
for(k=0; k<9; k++){
if (grid[j][k] > 0){
memcpy(possible_values[j][k], zero_string, 10);
}
}
}
for(j=0; j<9; j++){
for(k=0; k<9; k++){
if (grid[j][k] != 0){
help_variable_remove_pv = grid[j][k];
cast_number/*char*/ = (char) help_variable_remove_pv/*int*/;
printf("%c", cast_number); /*Gives out a smiley*/
printf("\n%d", cast_number); /*Gives out the number*/
}
}
}
int main(int argc, char *argv[])
int n, j, k, i;
int board [9][9];
printf("How many Sudokus should be solved: ");
scanf("%d", &n);
for(i=0; i<n; i++){
sudoku_read(board);
sudoku_solve(board);
}
return 0;
```