Im using this method
void * col_check(void * params) {
parameters * data = (parameters *) params;
int startRow = data->row;
int startCol = data->col;
int *colm = malloc(9);
for (int i = startCol; i < 9; ++i) {
int col[10] = {0};
for (int j = startRow; j < 9; ++j) {
int val = data->arr1[j][i];
if (col[val] != 0) {
colm[i]=i;
}
else{
col[val] = 1;
}
}
}
return colm;
}
i want to get the values in the colm array to the main program. So im using the below lines to do so. basically what the colm array stores are the column indexes of the arr1 which is not valid according to sudoku rules. (not important).
parameters * param10 = (parameters *) malloc(sizeof(parameters));
param10->row = 0;
param10->col = 0;
param10->arr1 = arr1;
void * cols;
pthread_create(&thread_10, NULL, col_check, (void *) param10);
pthread_join(thread_10, &cols);
printf("Calculating column validity please wait.\n");
sleep(mdelay);
int c;
int value= (int)cols[1];
i get the error "operand of type 'void' where arithmetic or pointer type is required" when i try to get the value in cols1 to the variable "value". What am i doing wrong ? any suggestions? Full code here
In (int)cols[1]
the (int)
part has lower precedence than the [1]
part, so the compiler tries to evaluate cols[1]
first.
Then the compiler cannot calculate cols[1]
because void*
does not point to an item of a known size. If the compiler does not know how large cols[0]
is, then how can it figure out where cols[1]
is?
I am not sure what you are trying to do, but what you probably want is int value = ((int*)cols)[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With