У меня возникает проблема, которая говорит:
warning: format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘uint8_t * {aka unsigned char *}
, и я не уверен, почему это происходит, потому что я думал, что int и uint8_t взаимозаменяемы.
Вот мой код:
uint8_t** fileRead(char* file, int* pointer) {
FILE* file = fopen(file, "r");
int count = 0;
pointer = &count;
fscanf(file, "%d", &count); //this retrieves a single integer
uint8_t** result = (uint8_t**) malloc(*pointer * sizeof(uint8_t*));
while (file != NULL) {
for (uint8_t i = 0; i < *pointer; i++) {
uint8_t* a = (uint8_t*) malloc(sizeof(uint8_t));
uint8_t* b = (uint8_t*) malloc(sizeof(uint8_t));
uint8_t* c = (uint8_t*) malloc(sizeof(uint8_t));
fscanf(file, "%d", a);
fscanf(file, "%d", b);
fscanf(file, "%d", c);
if (a == NULL || b == NULL || c == NULL) {
uint8_t* npointer = NULL;
fclose(file);
free(result);
return NULL;
} else {
result[i][0] = *a;
result[i][1] = *b;
result[i][2] = *c;
free(a);
free(b);
free(c);
}
}
}
return result;
}
, и ошибки происходят в следующих строках:
fscanf(file, "%d", a);
fscanf(file, "%d", b);
fscanf(file, "%d", c);
Большое спасибо заранее