警告:格式'%d'期望类型为'int *'的参数,但是参数3的类型为'uint8_t * {aka unsigned char *}] >> [

问题描述 投票:0回答:4
我遇到的问题是:

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);

非常感谢您

我一直遇到这样的问题:警告:格式'%d'期望类型为'int *'的参数,但是参数3的类型为'uint8_t * {aka unsigned char *},我不确定为什么会这样发生的原因是...

c segmentation-fault
4个回答
2
投票
我认为int和uint8_t可以互换。

2
投票

1
投票

1
投票
© www.soinside.com 2019 - 2024. All rights reserved.